Correct Answer to a HTTP-Post Request

Hi,

my problem is the response to a HTTP-Post request from IE. I wrote a webserver that opens a new socket connection on each request it handles. To be exact I am listening on port 80 and when a connection comes in, open a new socket, handle the request and then close the connection again.

This works great using HTTP-Get. But -Post requests do have a problem. I handle the request, then send some data back an close the connection again. On closing IE doesn't show my page, but instead shows an error page "Page cannot be displayed". I even still see the Get request coming in from the document I send back but the site never shows.

The browsers request looks like this:
[code]
POST /path HTTP/1.1
Accept: all types he accepts including */*
Referer: path with query-string
Accpet-Language: de
Content-type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; ...)
Host: localhost
Content-Length: 27220
Connecion: Keep-Alive
Cache-Control: no-cache
[/code]

and my answer is this:
[code]
HTTP/1.0 200 OK
Connection: close
Date: act. date
Server: myHTTPServer v.0.0.1
Content-Type: text/html
Content-Length: 21312
/*empty line*
DATA
[/code]

Am I missing something required Can I answer a HTP 1.1 request with HTTP 1.0 I did not implement Keep-Alive so I answer Connection: close.

Please somebody help, since I can't find info what answer IE expects. It works in Firefox ;-)

Greetz
Spanky


Answer this question

Correct Answer to a HTTP-Post Request

  • Nishant Sivakumar

    The idea is to call both, i.e. shutdown() and then closesocket().


  • J-Pixel

    Maybe its not what you're sending but the way you are closing the connection. Do you call shutdown()


  • Panish

    I thought shutdown closes immediately and close ends the Connection correctly Do I have to use either or Or only shutdown Because on only shutdown it seems like the process of IE is hanging in the state Close_Wait...

    thx

  • IceAngel89

    does nobody have a clue how to help

  • Laurent87471

    No I don't call shutdown(); I'm callin closesocket() in Winsock.h

  • morphius1

    The MSDN documentation suggests that you should always call shutdown() before closing a socket, although I'm not sure whether this is always necessary. How about trying it, to see if it makes any difference.


  • Correct Answer to a HTTP-Post Request