0

I have a server that accepts post requests. The post is sent from the Apache libraries.

BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream())); "some code here handles status line" While (input.ready) { line = input.readLine() if (line.length() == 0) break; System.out.println(line); } 

The problem is i never actually get the body? I only get the headers?

Thank you for any help

0

1 Answer 1

1
  1. Read headers with input.readLine();
  2. Skip 2 empty lines "\r\n\r\n"
  3. Read body while line.length() != 0.

So the format could look like:

Header1\r\n Header2\r\n Header3\r\n\r\n BODY BODY BODY... 

Another option is to use com.sun.net.httpserver.HttpServer

Sign up to request clarification or add additional context in comments.

1 Comment

even if i do this While (true) { line = input.readLine() System.out.println(line);} I only ever get the headers

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.