Solved

HTTP request (C/WinSock) What am I doing wrong?

Posted on 2001-09-13
3
1,291 Views
Last Modified: 2013-12-03
Hi all,

I am having trouble understanding why my HTTP request is not working properly.  Basically, I connect to a server on port 80, and send the following request:
"GET / HTTP/1.1\r\n"
and then I get nothing.  However, if I send the erroneous request:
"GET HTTP/1.1\r\n"
I get the expected response "HTTP/1.1 400 Bad Request ..."

Am I missing something?  I have tried various combinations of extra request headers with no luck.  Pointers/tips/useful websites are all appreciated!!

Thanks in advance to any expert!
0
Comment
Question by:zechis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
robpitt earned 300 total points
ID: 6480721
The data sent must terminate with a double CRLF i.e. \r\n\r\n

The correct thing to send for HTTP1.1 is:
 "GET /webpage.htm HTTP/1.1\r\nHost: www.thewebsite.com\r\n\r\n"

Note that the above ends in double CRLF.
The Host: line is mandatory for HTTP1.1

Rob
0
 
LVL 2

Author Comment

by:zechis
ID: 6480912
I am ever grateful!!

Quick question though, how did you find this out?  I read RFC 2068 backwards and forwards and don't remember seeing the double CRLF anywhere!
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6481849
It's all in there honest :-)
See section 4.1 Message Types - first couple of paragraphs.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question