Help me with making a HTTP client using WINSOCK.DLL

Status
Not open for further replies.

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,805
HTTP help required

I have to make a simple HTTP client using WINSOCK.DLL.

I have successfully made a connection to the server IP at port 80. But when I give it the command

GET index.htm HTTP/1.0

It results in <HTTP/1.0 400 Bad Request............ etc etc.

The same thing happens when I access any web server over the internet.

What am I missing.???
 

h**p help required

Try to replace h_t_t_p/1.0 with H_T_T_P/1.1 , but use capital letters, and place / before document name. A generic req. should look like:
GET / H_T_T_P/1.1 . Of course, remove the "_".


/pisoiu
 

h**p help required

the problem is something to do with the filename. On a local intranet server, it works fine. but on internet, it returns an error.
 

Re: h**p help required

techie said:
the problem is something to do with the filename. On a local intranet server, it works fine. but on internet, it returns an error.

Do not request a specific filename, make a request for a generic document, like:
GET / H.T.T.P/1.1 , take the first three points out, and use capitals.
If you specify at the requested URI the "/", the server will return the index document. Try to listen the traffic on port 80 with an ethernet sniffer and see how a standard web browser make this request.

/pisoiu
 

h**p help required

I did and found out.

I was missing the "Host: myhost.com" command.

It is working now
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…