Announcement

Collapse
No announcement yet.

Which Header Lines Are Required?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Which Header Lines Are Required?

    This minimal code (only the initial line in the header - no other header lines) works to download a small file, but I wondered if there were any other header lines in the request that I should add? Perhaps I was just lucky in having only the initial line?

    I looked on the web but couldn't find a discussion on which lines are required. For all I know, it may be also considered impolite if I don't include certain headers line?

    Code:
       Tcp Open "HTTP" AT "www.garybeene.com" AS #1 TIMEOUT 60000
       Tcp Print #1, "GET  /files/tcp_test.txt  HTTP/1.0"
       Tcp Print #1, ""
       Tcp Recv #1, 4096, Buffer$
       Tcp Close #1
    If there's a reference to read, that would be nice to know as well.

  • #2
    You just require the one REQUEST line, but you can include other Header information if so desired.

    For HTTP 1.0 which you are using , the
    prime reference is RFC 1945
    http://www.w3.org/Protocols/rfc1945/rfc1945

    for HTTP 1.1, the reference is RFC 2616
    http://www.w3.org/Protocols/rfc2616/rfc2616.html

    See Sections 4 aand 5 of the reference for info on Headers.

    Comment


    • #3
      Stuart, thanks for the response. The answer was what I hoped it would be!

      Comment


      • #4
        I believe it's important you also include a "Host: site.com" header after your first one. I think it is important for virtual hosts and anywhere a server is hosting more than one domain from one IP.

        I've always included the request, host, and User-Agent (claiming to be IE) and have never had any issues.

        You may find, when dealing with dynamically created web pages, that your inclusion or exclusion of a user agent (and what it claims to be) could be the reason you are or aren't getting the data you wanted.
        LOCAL MyEMail AS STRING
        MyEmail = STRREVERSE$("53pmohtj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")

        Comment


        • #5
          I've been adding the Host header as well but only when using HTTP/1.1. I think it is required for HTTP/1.1 but HTTP/1.0 doesn't require any headers if I remember correctly.
          Jeff Blakeney

          Comment


          • #6
            I think it might just depend on if it's a shared server with virtual hosts.

            If I've got Apache serving ten different domains...

            Code:
               Tcp Open "HTTP" AT "www.garybeene.com" AS #1 TIMEOUT 60000
               Tcp Print #1, "GET  /files/tcp_test.txt  HTTP/1.0"
               Tcp Print #1, ""
               Tcp Recv #1, 4096, Buffer$
               Tcp Close #1
            ...doesn't tell me which domain you're requesting from.

            I don't know how it would get around it (unless anything HTTP/1.0 could only serve one domain and no virtual hosts?), but if anything unusual happens maybe throw one in there.

            -John
            LOCAL MyEMail AS STRING
            MyEmail = STRREVERSE$("53pmohtj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")

            Comment

            Working...
            X