[Ilugc] [TIP] C language code to download file using HTTP

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Wed, 16 Nov 2011 11:28:52 +0530

On Wed, Nov 16, 2011 at 11:00 AM, Balachandran Sivakumar
<benignbala at gmail.com> wrote:

Hi,

On Wed, Nov 16, 2011 at 7:54 AM, Girish Venkatachalam
<girishvenkatachalam at gmail.com> wrote:

#define HTTP_GET_CMD "GET /%s HTTP 1.1\r\n\r\n"


? ? ? Not nitpicking, but I guess that's an RFC violation ;) HTTP 1.1
says Host header is mandatory. From RFC 2616, :

Okay. I only get irritated when people don't talk technical. You do and it is a
 genuine flaw. No problem. I am only glad.

Only that I dunno how to fix it. Are you supposed to say something like:

"HOST foobar \r\n\r\n"

or something?

I am sure it is before the GET right?

I am aware of many other flaws too. Like this won't work with HTTP 301
redirects as is the
 case with tinyurls which is what Shrinivasan is fond of.

And I am definitely not RFC compliant since I said that URL encoding
is not handled. And I don't
 handle all the header responses. So this is not a surprise.

Can you throw some light on your point please?

Moreover my point was only a broad example to illustrate the concept.

One has to build on top of it. It has educational value and gives a
real life kick.

For something professional more work is required.

But it is also a truth of life that majority of professional
commercial grade code is not
standards compliant.


"A client MUST include a Host header field in all HTTP/1.1 request messages ."


Good. I am glad there is someone talking of RFC standards. Good. Keep it up.

And nice initiative. People on the list, new to socket programming can
possibly start with this. Thanks


Doesn't anybody want a code walk through?

Unless someone asks I am not gonna do it.

-Girish

Other related posts: