Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3879334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:42:52+00:00 2026-05-19T22:42:52+00:00

First of all, I’ll admit this is a school project, so I need more

  • 0

First of all, I’ll admit this is a school project, so I need more of just direction, rather than actual code. Also, I cannot use the java.net.HTTPURLConnection and java.net.URL classes to help out…

Ok… I’m creating a HTTP server in Java, but having trouble reading HTTP messages. I need to allow persistent connections (when using HTTP/1.1 and no Connection: close), which is already working. But because of the persistence, there might be multiple requests coming down the pipeline.

I know I can use the Content-Length header to determine how long the message body will be, in bytes. After that, the next message will come down the pipe.

My questions…

  • Should I read in the message byte by byte or char by char, or can I read in line by line? Going line by line would be fine until hitting the message body…
  • Should the message body be saved in byte format, or is String ok (I know HTML is fine, but will images, etc. break if going through a String?)
  • Is there a scanner that will let me read line by line, and then when I hit the message body, call a getBytes( contentLength ), and it gives me the body?

Thanks again!

Edit: I do not have to support chunked or compressed data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:42:52+00:00Added an answer on May 19, 2026 at 10:42 pm

    I suggest reading into byte-arrays. And don’t read line wise, but read in chunks of bytes (you can try to use content-length as your chunk size. Beware that read(byte[]) returns the number of bytes actually read and you still may have to call it several times).

    Also beware of chunked encoding, although I admit that I do not know whether servers must support this since I always just cared for coding clients.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, pardon my hacky code, I'm just trying to try this out
i have this code which i use in order to extract first all users
I have this code below, with which I select first all id's from table
First of all, sorry for my English :(. Hi, I've this code to download
First of all, this isn't for a keylogger, it's for an input in a
First of all there is probably a question like this already but i couldn't
First of all, apologize because I have seen some posts about this, but I
First of all I want to mention two things, One: My code isn't perfect
First of all, I am sorry if this question doesn't belong to SO since
First of all, I don't need a textual comparison so Beyond Compare doesn't do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.