I have established the connection to the host and everything is going smoothly
below is the header i have sent to the server

GET /mainpage/main.html HTTP/1.1
Host: Http://www.*******-*******.com
User-agent: MyProgram
Connection: close

in return i got this message : Bad Request (Invalid Hostname)

i set the host to www.google.com and the URL to / and the program works fine

any ideas why ?

Posted on 2006-04-07 00:14:18 by XCHG
Is it a proxy?  If it is you will have problems.

Paul
Posted on 2006-04-07 00:55:48 by PBrennick

GET /mainpage/main.html HTTP/1.1
Host: *******-*******.com
User-Agent: MyProgram
Connection: close


Host is the hostname, not the host url. Don't use http://www stuff, it's not needed.

EDIT: just a quick question (after seeing what that site is).. what exactly are you developing?

Regards,
Bryant Keller

Posted on 2006-04-07 02:14:36 by Synfire
XCHG, please familiarize yourself with our Community Rules. I have edited the link you posted due to content issue that are against our Community Rules.

The basis of the Community Rules in this respect is to prevent middle-man linking which effectively brings unwanted people to this place. You don't have to give away everything you are doing, but please don't say anything that will compromise this standard.

To back Synfire, the Host is the domain name "something.com", the "www" subdomain is not needed unless it points to a different IP address.
Posted on 2006-04-07 04:12:39 by SpooK
Also, the spec states that the request should contain full address, and the host should contain port number. like this:

GET http://forum.asm.free.com/index.php HTTP/1.1
Host: forum.asm.free.com:80
Connection: Close
User-Agent: My_Cool_Agent
Accept-Encoding: gzip, deflate
Posted on 2006-04-07 08:00:30 by ti_mo_n
If no port number is specified, port 80 is assumed. In practice, proxies and servers ignore the port; but the do use the hostname, since a single IP could serve many hosts.
Posted on 2006-04-07 11:57:17 by QvasiModo
The primary reason for the Host: argument is for server software which contains multiple sites. For example, the codefoo.ath.cx and nasm32.ath.cx sites are on the same server. When a web browser connects it connects to an IP address and port then asks for a file starting from / in the hosts directory tree. If no Host: option was given you would get the fnx-project.co.uk / directory. But when Host: is passed, the server takes that value and checks it's configurations for the / directory of the associated host on that server. Because of this the / directory for codefoo.ath.cx, nasm32.ath.cx, and fnx-project.co.uk can have their own independant directories.

Regards,
Bryant Keller
Posted on 2006-04-07 18:10:04 by Synfire
Sorry guys for posting the URL
and thanks for all your help

It was the HTTP:// tag that i was attaching to the URL that was stopping the program from working properly

i excluded that from the header and it's working fine now.

thanks again, i appreciate it
Posted on 2006-04-08 22:28:51 by XCHG
No problem, just keep in mind that "http://" is a URI/URL indictor to access domain name at "Port 80"... an abstract usually used by web browsers and the such ;)
Posted on 2006-04-08 22:36:47 by SpooK
To expand on what Spook said, the xxx:// is mearly the protocol identifier. This means that if the browser is setup correctly, whatever protocol is listed before the :// is usually launched using the appropriate application. In your case it's the HTTP protocol (http://) which means that your browser will handle the connection itself. If say you used ftp:// you're browsers association to the FTP protocol would be loaded, or irc:// would load the browser association for the IRC protocol. Some browsers don't let you set these and ignore everything they don't support, other browsers such as FireFox can be internally configured to launch other applications (I currently have irc:// load up XChat ssh:// load up PuTTY and ftp:// load up FTP.EXE from the command line). It's mearly a protocol specifier for your browser, it has no part in the actual HTTP protocol itself.
Posted on 2006-04-08 22:59:31 by Synfire
If you are making a simple HTTP engine, you might want to use HTTP/1.0 instead of 1.1.  Most servers support 1.0 and you won't have to deal with chunked responses.  A proper 1.1 client engine is pretty complicated and IMHO is best served by asynchronous socket calls.
Posted on 2006-04-21 22:43:17 by rdaneel