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

  • From: benignbala@xxxxxxxxx (Balachandran Sivakumar)
  • Date: Wed, 16 Nov 2011 12:28:31 +0530

Hi,

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

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

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?


No, it is after GET. It is something like this

GET http://someurl.something/xyz HTTP/1.1\r\n
Host: someurl.something\r\n
\r\n

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.


       True, but since this is a simple program to download
something(I guess this is intended more towards learning than
real-life usage), we cannot be fully RFC compliant with regards to
HTTP responses. :)

Can you throw some light on your point please?


      The point is, since it is an RFC "MUST", I am not sure if all
servers will process the request if it doesn't have a HOST Header. If
we are sure they will process, then this is not even an issue. For a
simple learn-networking script, it should be more than sufficient.

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.


Yeah :)

Doesn't anybody want a code walk through?

Unless someone asks I am not gonna do it.


       I assumed it would be part of the TIP itself :). Thanks for the
code though.


-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?- Swami Vivekananda

Mail: benignbala at gmail.com
Blog: http://benignbala.wordpress.com/

Other related posts: