Re: HTTP coding of Last-Modified requests?

Stephen Zagerman wrote:
> 
> I need to write a small app that checks the Last modified date of a web
> page and have read. So, having read the HTTP reference docs it seems that
> opening a TCP/IP connection and issuing an HTTP request is the way to do
> it. I'm a little confused though...
> 
...

> Some questions:
> 
> 1)  Is the method to be used GET or HEAD?
> 

HEAD

> 2) Is the ProtocolVersion required?
> 

Yes, omitting it implies HTTP/0.9 which does not support HEAD.

> 3) The "Last-Modified" fieldname is part of the HTRQ Header? Since I'm
> asking for the date, what would be put in the "Value" part of the HTRQ
> Header?
> 

You don't supply the Last-Modified header, the server does.  See below.

...
> For example, if I want to find out if the page at "www.page.com/index.html"
> had changed, would the following work?
> 
> a) Open a connection to www.page.com.
> 
> b) Issue the following text (without the quotes) for the request:
> 
> "HEAD /index.html HTTP/1.0 CrLf Last-Modified : CrLf"
> 

The text sent should be 

        HEAD /index.html HTTP/1.0<CRLF>
        <CRLF>

where <CRLF> indicates carriage return line feed, i.e. don't 
send '<' or '>'.  You can try this by telneting to port 80 on a 
Web serving and typing the lines above to see what the server will
send. 

For example, I ran the command "telnet hopf.math.nwu.edu 80" and 
typed "HEAD /index.html HTTP/1.0"  followed by two carriage returns.
The response from the server was

  HTTP/1.0 200 OK
  Server: WN/1.14.0
  Date: Wed, 29 May 1996 17:35:24 GMT
  Last-modified: Wed, 08 May 1996 16:41:16 GMT
  Content-type: text/html
  Title: WN -- a server for the HTTP
  Keywords: WN, HTTP server


From this you will have to extract the last modified date.  Hope
this helps.

John Franks 	Dept of Math. Northwestern University
		john@math.nwu.edu

Received on Wednesday, 29 May 1996 13:37:42 UTC