java - Buffered Reader HTTP POST -


Looking for some help, I have currently written an HTTP server, it currently handles the OK GET request. However, buffer reader seems hanging while using the post. When the request is stopped, the remaining input stream is read through the buffer reader. I have found a few things on Google. I have tried to change the CRLF and the protocol version from 1.1 to 1.0 (Browsers automatically request as 1.1) Any ideas or help would be appreciated. Thanks

I agree with Swan that you should do a standard and thorough investigation The library should be used. However, if you are writing a server to learn about HTTP, then there is some information about what you want to do.

You can not actually use a Buffer Reader because it buffers input and can read many bytes, because this is the reason that your code is hanging, bytes available on the buffer reader socket Trying to read (since POST is not the end of data), and it is waiting for more bytes (which will never be available)

The process of parsing the POST request is to use direct inputstream

  • For each row in the header, read one byte at a time when Find a line starting with a '\ r' and then '\ n'

  • "Content-Length:", then at the end, remove the number That line

  • When you get a header line which is empty, then you have done it with the header.

  • Read now the exact type of bytes coming from content-length headers

Now you can write your answer.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -