Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    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-05-2011 at 12:32 AM. Reason: Added information


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts