tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wade Chandler <wchand...@redesetgrow.com>
Subject Re: Handling HEAD request in servlet
Date Fri, 07 Jan 2005 06:17:50 GMT
Tennessee Leeuwenburg wrote:
> Glad to find another human! :)
> 
>  From the spec, it looked like there should be a content-length, but 
> maybe you're right. I'm writing a server for a client that expects the 
> content-length to be there. As I said, I did find a workaround by just 
> printing to the output stream, but it had me baffled for a while. Lucky 
> everyone is still on holidays, there was some swearing going on :)...
> 
> Cheers,
> -T
> 
>> Yeah, you should have seen another message between me and another guy. 
>> lol.  Anyways, head responses can't have a length as they are only a 
>> header.  So basically all you can send back in a head request is the 
>> header and the header won't have a length....read the headers until 
>> you get an empty line....if that's what you are needing to do (client 
>> stuff)...server side...you can't really do anything with the head 
>> request but send headers.  I guess you can send a header for a 
>> redirect to a different page if needed.  So I'm sure tomcat is wiping 
>> it all out for you ... as it should be technically per the specification.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
No I think you should be able to set the header......Tomcat does it for 
me on my home directory index.html file.  Here is the output from the 
head operation...

HTTP/1.1 200 OK
ETag: W/"697-1078786629000"
Last-Modified: Mon, 08 Mar 2004 22:57:09 GMT
Content-Type: text/html
Content-Length: 697
Date: Fri, 07 Jan 2005 06:14:26 GMT
Server: Apache-Coyote/1.1
Connection: close

That from my Tomcat 5.0.28 ~useraccount index.html file.  I used w3m to 
perform a head.

and this from a zip file I had in there....


HTTP/1.1 200 OK
ETag: W/"1169293-1084811760000"
Last-Modified: Mon, 17 May 2004 16:36:00 GMT
Content-Type: application/zip
Content-Length: 1169293
Date: Fri, 07 Jan 2005 06:18:19 GMT
Server: Apache-Coyote/1.1
Connection: close


Which makes sense...why else would one want HEAD in the first place if 
not to examine the data a tad before trying to grab it.

Maybe don't try to set the content and just try to set the header itself 
without calling the method to set the content?  Have you already tried 
that....setting the header and leaving the content property alone? 
Maybe you are calling something else after setting the header that is 
clearing it out....?

Wade


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message