By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

Http server - Header problem

P: n/a
Hi,
I need to have a simple http server in one of my applications. It's
just for a little text data so i wanted to write my own.
So i have a listener on port 80 and i'm using async methods to receive
/ send data. My problem is, i found lots of sample web server
applications, all of them just calls socket.read method for 1-4kb data.
And parses the response for headers. Isn't it possible to receive
partial data from socket and break this method? I mean i do telnet
google.com:80 and write my request, server doesn't respond till i send
double newline.
What would you suggest? Just read once and go or check received data
for CRLF+CRLF?

Dec 14 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> What would you suggest? Just read once and go or check received data
for CRLF+CRLF?
No, there is no warranty that one read will bring you whole request.

you have to read until CRLF+CRLF is encountered. But it is not the end. this
approach will be suffice only for GET requests as there is no content
following...
if you issue POST requests then you have to obtain HTTP header ( ends with
double CRLF ) and then find field Content-Length and its value.

Then read until you receive Content-Length bytes of the info.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

<an*****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com... Hi,
I need to have a simple http server in one of my applications. It's
just for a little text data so i wanted to write my own.
So i have a listener on port 80 and i'm using async methods to receive
/ send data. My problem is, i found lots of sample web server
applications, all of them just calls socket.read method for 1-4kb data.
And parses the response for headers. Isn't it possible to receive
partial data from socket and break this method? I mean i do telnet
google.com:80 and write my request, server doesn't respond till i send
double newline.
What would you suggest? Just read once and go or check received data
for CRLF+CRLF?

Dec 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.