Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: HTTP Requests and Responses
02-04-2011, 11:19 PM #1
- Join Date
- Sep 2008
- Thanked 0 Times in 0 Posts
HTTP Requests and Responses
Hello yall. So I will go ahead and say I am working on a http server and client for a class. I already had to make a server in C, but now I have to do the same in Java. I am not looking for code just and understanding about some concepts. I am able to request and get a response for text based files like htm, html, txt, etc. However I am having trouble with any other type of files like pdfs and jpgs for example.
My question is when I am requesting a pdf for example, will the headers for the response still be just plain text? Also what format would the body of the response be in? Using the InputStream class of java.net , I know that data is read in in bytes which I then must convert to be able to decipher the headers. Text based files are easy because I can just convert everything, header and body. My previous C server only dealt with serving text based files so this is new to me. I appreciate any help.
The overall problem is that we have to pipeline requests. So when I start trying to receive files, I first have to read in some things in bytes, convert that to a String so I can parse it for the "content-length:". Since I cannot know ahead of time how many bytes are for the header, I could accidently convert the bytes of the body into a String which I do not think I want to do if the file is a pdf.
Last edited by jbm715; 02-04-2011 at 11:32 PM. Reason: Added information