You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by Dmitry the Zuryanovich <dt...@XEPb.ru> on 2005/05/14 15:03:47 UTC
HEAD request
Hello there,
I have a directory with ErrorDocument 404 /feed/holder.rvt in .htaccess .
When I get a GET request, holder.rvt is launched and works fine.
But HEAD request gets 404 Not found response.
Is it an apache problem or rivet-specific? What to do?
--
DtZ (homepage:http://xepb.ru/dtz ,ICQ UIN:5132840,Fido: 2:5020/730)
jabber://dreadbit@jabber.ru //HPG
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
if (r->header_only)
{
TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, globals->req);
TclWeb_PrintHeaders(globals->req);
retval = OK;
goto sendcleanup;
}
There's the code that's actually causing it to behave differently than
you expect. If you really wanted, you could take that out, but I think
it would also mean that it would spit out the whole file for each HEAD
request. Perhaps a better way would be to do some checking, and if the
headers have already been printed, just not send anything to the client
anymore. Kind of complex for a very corner case, though...
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
>On Thu, May 19, 2005 at 11:01:25PM +0200, David N. Welton wrote:
>
>
>>>I think there is no difference beetween GET and HEAD. I just want to get
>>>the equal results ;-) I use the "black-box" cybrenetic way.
>>>
>>>
>>There is a definite difference between GET and HEAD.
>>
>>
>
>Well, is that's a my /as the developer using mod_rivet/ problem? I just
>serve the request. I serve the content. And I *must* get the request inside of the rivet code I expect it to serve.
>
>
I think the best "quick fix" is to try taking out that code that I
listed below. See if that works. If it does, then we can think about
how to make things work in general.
>>You mean it doesn't actuall pass those as part of the URL?! Well, with
>>mod_rewrite you can still work around that. You can remap something like:
>>
>>
>
>Well, this problem is allready solved. I just map the CGI-style stuff
>(all that ? and &'s) to the virtual directory. And I map the
>Sony-Ericsson's hated = to -'s.
>
>
This is a distinct problem, different from GET vs HEAD, but I'm
convinced that to solve it you should use mod_rewrite instead of a 404
handler.
>>>>Well, I think if the GET works, why should I care about HEAD? I do not
>>>>want to install the mod_rewrite for HEAD.
>>>>
>>>>
>>mod_rewrite ships with Apache, isn't really all that bulky, and does
>>exactly what you need. I think it's the best solution.
>>
>>
>
> Well, you do not understand me. I think that GET and HEAD is exactly
>the same thing handled by apache and calling _my_ script. Including the case of
>HEAD the requester gets only the real head of the request (while I HOLD IT!).
> If you say "I cant do it now" - well, I'll rewrite it in some
>other technology, no problem. May be even with mod_rewrite.
>
>
I think PHP is going to do the same thing Rivet does with HEAD requests
- well, it may do some headers, but it won't actually send out a body.
Try the quick fix solution and see if that works to solve your immediate
problem, then we can go from there to come up with a general solution.
>>>You may not trust me, but is DOES only for .mid files, not for .jad/.jars ;-)
>>>I'm shocked ;-)
>>>
>>>
>>Weird. I think I'd have to see some dumps and traces to really get an
>>idea of what's going on.
>>
>>
>
>Well, thay have a right to send HEAD. Why the 610 and 630 does it only
>for .mid files - I do not know.
>
>
They can send HEAD all they want, but they shouldn't expect to get
anything more than headers back:-) Anything else is really going
outside the protocol. We can figure out a way to make it work for you,
but it's not going to necessarily be folded back into the Rivet sources...
>>>We are playing with the SMPP 3.4 (written on Perl on hacked version of
>>>Net::smpp) as the smpp daemons while the site is written on rivet (
>>>undersite, www.undesite.ru, in english ;-) )
>>>Mysql, base64::encode and to the database. It works ;-)
>>>
>>>
>> I saw it ;-) That's cool - but it just a sort of "TCL IS PORTABLE!".
>>Does it has some practical usage?
>> As for me, I want some other-than-java programming language compiling
>>to J2ME devices.
>> Java bores me ;-(
>>
>>
It's not quite Tcl, and the point is eventually to be able to write
scripts, instead of compiled code, for J2ME devices.
>>I might also do some WML for a few sites I run, but I'm still thinking
>>about it. I don't get if there's a way to make any money from it since
>>you can't really do advertisements or anything like that.
>>
>>
>
> The main problem of WML is that you *must* keep your's pages under
>1.5kilobyte weight. But - not exactly, in compiled mode! Do you know
>that "http://www." is represented as ONE byte (while wap server compiles
>your's WML page to the content it actually sends)?
>
>
Hrm, I think for what I need (nothing fancy), it's all doable.
>>Ah, well what I had to say is that I found the code that cuts things off
>>when using HEAD:
>>
>>
See if commenting it out fixes things, and let us know.
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
>On Wed, May 18, 2005 at 10:57:28PM +0200, David N. Welton wrote:
>
>
>>I'm going to CC the rivet-dev list, though, because it's an interesting
>>discussion! I hope you don't mind...
>>
>>
>
>No, I do not mind ;-)
>
>
Ok...
>>Aha! This is what I suspected you were trying to do. The problem is
>>that you are fighting against Apache instead of working with it. What
>>you want to do is map a URL to some sort of virtual actions...
>>
>>
>
>I think there is no difference beetween GET and HEAD. I just want to get
>the equal results ;-) I use the "black-box" cybrenetic way.
>
>
There is a definite difference between GET and HEAD.
>>... and I *think* the response in this case is mod_rewrite, combined
>>with Rivet. With mod_rewrite, for instance, you could remap
>>/feed/SMTHSTRANGE/name.of/file to:
>>foo.tcl?encnum=SMTHSTRANGE&filename=name.of/file...
>>
>> As I said, the dump SonyErricson devices decides & and ? and = are the
>>URL terminators. Today I've got a positive results with WAP PUSH , but
>>it does not cancels the HEAD thing.
>>
>>
You mean it doesn't actuall pass those as part of the URL?! Well, with
mod_rewrite you can still work around that. You can remap something like:
/foo/bar/bee/bop/
to (internally)
/foo/bar/?bee=bop
So that the browser never sees what the real URL is...
>> Well, I think if the GET works, why should I care about HEAD? I do not
>>want to install the mod_rewrite for HEAD.
>>
>>
mod_rewrite ships with Apache, isn't really all that bulky, and does
exactly what you need. I think it's the best solution.
>> If not, I'll rewrite the code on PHP or even CGI, but.. I just want
>>rivet to do this work ;-)
>>
>>
I'm sure there's a way to make it work.
>>>The mobile phones are really dump. SonyErricsson says that = is a terminator
>>>for the url, while Alcatel says it's a regular symbol. SonyErriccson sends
>>>HEAD while Alcatel/Motorola just GETs.
>>>
>>>
>>It sends HEAD to get a resource?! Wow...
>>
>>
>
>You may not trust me, but is DOES only for .mid files, not for .jad/.jars ;-)
>I'm shocked ;-)
>
>
Weird. I think I'd have to see some dumps and traces to really get an
idea of what's going on.
>>>Most of them says ? and & are a URL terminator, so I use the virtual directories.
>>>
>>>
>>In what sense?
>>
>>
>
> Until today I just send the url as the plain sms message. Most of mobile phones
>(excluding Samsung X600) asked me - "Do you want to follow the URL?"
> Sony Ericsson (T610/T630) also asked me, but they said URL is
>terminated by ? and & symbol (a sort of castrated URLs).
> Samsung _never_ asked me about if I want to follow the URL, so I moved
>to WAP PUSH.
>
>
>
>>Interesting... I'm looking at doing a bit of experimentation with mobile
>>phones myself.
>>
>>
>
>We are playing with the SMPP 3.4 (written on Perl on hacked version of
>Net::smpp) as the smpp daemons while the site is written on rivet (
>undersite, www.undesite.ru, in english ;-) )
>Mysql, base64::encode and to the database. It works ;-)
>
>
Cool! What I'm working on, off and on, is a programming language that
runs on J2ME devices:
http://www.hecl.org
I might also do some WML for a few sites I run, but I'm still thinking
about it. I don't get if there's a way to make any money from it since
you can't really do advertisements or anything like that.
>>>I'll try, but I'm _sure_ the TCL code is not executed.
>>>
>>>
>>It isn't - see my follow up message:-)
>>
>>
>
>I do not see it neither in maillist, nor here.
>
>
Ah, well what I had to say is that I found the code that cuts things off
when using HEAD:
if (r->header_only)
{
TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, globals->req);
TclWeb_PrintHeaders(globals->req);
retval = OK;
goto sendcleanup;
}
On about line 500 of mod_rivet.c
You could try fiddling with that (removing it) and see if it does what
you need.
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
>On Wed, May 18, 2005 at 01:54:59PM +0200, David N. Welton wrote:
>
> Hi David, looks like this message is more ideologic than rivet-specific,
>so I reply directly to you.
>
>
I'm going to CC the rivet-dev list, though, because it's an interesting
discussion! I hope you don't mind...
>>numeric headers on something that should be a 404? Perhaps there is a
>>better way of doing things?
>>
>>
> No! I look at the httpd server as the gateway (sort of API) between
>HTTP protocol and application.
> When I say "Get this! (200)" I just say - "this content is avaluable TO YOU".
>I do not care about the particular file.
>
> In my case, I offer some content to the mobile phones (prevously ordered by SMPP
>/Send-The-SMS-Message-And-Get-The-Shit/). I have to check if the file was payed
>by the requester and so on (the tricky /feed/SMTHSTRANGE/nameof.file).
>
> The content is _absouletly_ virtual. It's _not_ a file, and I think that's
>normal. (I 'puts' it to stdout, prevously configured it to -encoding binary or
>like that)
> Looks like you came in www space in the Old Times where the requesters
>required The File ;-) In 1993, I suppose? ;-)
>
>
Aha! This is what I suspected you were trying to do. The problem is
that you are fighting against Apache instead of working with it. What
you want to do is map a URL to some sort of virtual actions...
... and I *think* the response in this case is mod_rewrite, combined
with Rivet. With mod_rewrite, for instance, you could remap
/feed/SMTHSTRANGE/name.of/file to:
foo.tcl?encnum=SMTHSTRANGE&filename=name.of/file...
using regular expressions. This is far more elegant and powerful than
trying to back out of a 404 at the last minute.
Check out this and see if what it says works for you:
http://httpd.apache.org/docs/misc/rewriteguide.html
> The mobile phones are really dump. SonyErricsson says that = is a terminator
>for the url, while Alcatel says it's a regular symbol. SonyErriccson sends
>HEAD while Alcatel/Motorola just GETs.
>
>
It sends HEAD to get a resource?! Wow...
> Most of them says ? and & are a URL terminator, so I use the virtual directories.
>
>
In what sense?
>>>GET /feed/NzA5NTEwMjU2MTA_/timofeevgennadii-hozyaikabara.mid HTTP/1.0
>>>
>>>
> The NzA5NTEwMjU2MTA_ is actually is base64 encoded mobile number phone
>with [string map {= _} $phone]
>
>
Interesting... I'm looking at doing a bit of experimentation with mobile
phones myself.
>>You could check and see if in the HEAD case, the Tcl code is even being
>>run. One way to do this is something like:
>>
>><?
>>set fl [open /tmp/foobar w]
>>puts $fl [clock seconds]
>>close $fl
>>?>
>>
>>
>I'll try, but I'm _sure_ the TCL code is not executed.
>
>
It isn't - see my follow up message:-)
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
> Well, as for my case I use
>
> headers numeric 200
>
>
Hrmm.... that sounds like a recipe for trouble to me:-)
What are you trying to accomplish... I mean, why are you playing with
numeric headers on something that should be a 404? Perhaps there is a
better way of doing things?
>, so maybe that's why I get an another result:
>
>bash-2.05$ telnet teleboom.ru 80
>Trying 217.16.26.184...
>Connected to teleboom.ru.
>Escape character is '^]'.
>GET /feed/NzA5NTEwMjU2MTA_/timofeevgennadii-hozyaikabara.mid HTTP/1.0
>
>
>HTTP/1.1 200 OK
>Date: Wed, 18 May 2005 09:07:11 GMT
>Server: Apache/1.3.33 (Unix) Rivet mod_ssl/2.8.22 OpenSSL/0.9.7d
>Content-disposition: attachment; filename=timofeevgennadii-hozyaikabara.mid
>Connection: close
>Content-Type: audio/midi
>[midi file follows]
>
>and
>
>bash-2.05$ telnet teleboom.ru 80
>Trying 217.16.26.184...
>Connected to teleboom.ru.
>Escape character is '^]'.
>HEAD /feed/NzA5NTEwMjU2MTA_/timofeevgennadii-hozyaikabara.mid HTTP/1.0
>
>HTTP/1.1 404 Not Found
>Date: Wed, 18 May 2005 09:07:47 GMT
>Server: Apache/1.3.33 (Unix) Rivet mod_ssl/2.8.22 OpenSSL/0.9.7d
>Connection: close
>Content-Type: text/html
>
>Note not only 404, but text/html also - HEAD request was not handled ;-(
>
>
You could check and see if in the HEAD case, the Tcl code is even being
run. One way to do this is something like:
<?
set fl [open /tmp/foobar w]
puts $fl [clock seconds]
close $fl
?>
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by Dmitry the Zuryanovich <dt...@XEPb.ru>.
On Wed, May 18, 2005 at 12:46:39AM +0200, David N. Welton wrote:
> >>>I have a directory with ErrorDocument 404 /feed/holder.rvt in .htaccess .
> >>>When I get a GET request, holder.rvt is launched and works fine.
> >>>But HEAD request gets 404 Not found response.
> >>>Is it an apache problem or rivet-specific? What to do?
> >>Looks as if it may indeed be a Rivet thing. I see this in the code:
[skipped]
> >M_HEAD is not defined in apache includes.
> Oops - indeed.
> I went back and thought about this, and everything is working as it should:
> davidw@florence:~$ GET -s http://localhost/doesntexist
> 404 Not Found
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> ...
Well, as for my case I use
headers numeric 200
, so maybe that's why I get an another result:
bash-2.05$ telnet teleboom.ru 80
Trying 217.16.26.184...
Connected to teleboom.ru.
Escape character is '^]'.
GET /feed/NzA5NTEwMjU2MTA_/timofeevgennadii-hozyaikabara.mid HTTP/1.0
HTTP/1.1 200 OK
Date: Wed, 18 May 2005 09:07:11 GMT
Server: Apache/1.3.33 (Unix) Rivet mod_ssl/2.8.22 OpenSSL/0.9.7d
Content-disposition: attachment; filename=timofeevgennadii-hozyaikabara.mid
Connection: close
Content-Type: audio/midi
[midi file follows]
and
bash-2.05$ telnet teleboom.ru 80
Trying 217.16.26.184...
Connected to teleboom.ru.
Escape character is '^]'.
HEAD /feed/NzA5NTEwMjU2MTA_/timofeevgennadii-hozyaikabara.mid HTTP/1.0
HTTP/1.1 404 Not Found
Date: Wed, 18 May 2005 09:07:47 GMT
Server: Apache/1.3.33 (Unix) Rivet mod_ssl/2.8.22 OpenSSL/0.9.7d
Connection: close
Content-Type: text/html
Note not only 404, but text/html also - HEAD request was not handled ;-(
--
DtZ (homepage:http://xepb.ru/dtz ,ICQ UIN:5132840,Fido: 2:5020/730)
jabber://dreadbit@jabber.ru //HPG
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
>On Sun, May 15, 2005 at 06:08:42PM +0200, David N. Welton wrote:
>
>
>>>I have a directory with ErrorDocument 404 /feed/holder.rvt in .htaccess .
>>>When I get a GET request, holder.rvt is launched and works fine.
>>>But HEAD request gets 404 Not found response.
>>>Is it an apache problem or rivet-specific? What to do?
>>>
>>>
>>Looks as if it may indeed be a Rivet thing. I see this in the code:
>>
>> r->allowed |= (1 << M_GET);
>> r->allowed |= (1 << M_POST);
>> if (r->method_number != M_GET && r->method_number != M_POST) {
>> retval = DECLINED;
>> goto sendcleanup;
>> }
>>
>>
>
>M_HEAD is not defined in apache includes.
>
>
Oops - indeed.
I went back and thought about this, and everything is working as it should:
davidw@florence:~$ GET -s http://localhost/doesntexist
404 Not Found
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
...
davidw@florence:~$ HEAD -s http://localhost/doesntexist
404 Not Found
Connection: close
Date: Tue, 17 May 2005 22:44:03 GMT
Accept-Ranges: bytes
ETag: "3e423e-17f-428a6c6a;428a7115"
Server: Apache/1.3.33 (Debian GNU/Linux)
Content-Length: 383
Content-Type: text/html; charset=iso-8859-1
Last-Modified: Tue, 17 May 2005 22:12:58 GMT
Client-Date: Tue, 17 May 2005 22:44:03 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Of *course* it's a not found, that's the whole point of 404 :-) The GET
request returns a 'not found' too, just that it gives you some HTML to
look at while you are contemplating the missing page... So everything
is working as it should be.
--
David N. Welton
- http://www.dedasys.com/davidw/
Apache, Linux, Tcl Consulting
- http://www.dedasys.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by Dmitry the Zuryanovich <dt...@XEPb.ru>.
On Sun, May 15, 2005 at 06:08:42PM +0200, David N. Welton wrote:
> > I have a directory with ErrorDocument 404 /feed/holder.rvt in .htaccess .
> > When I get a GET request, holder.rvt is launched and works fine.
> > But HEAD request gets 404 Not found response.
> > Is it an apache problem or rivet-specific? What to do?
> Looks as if it may indeed be a Rivet thing. I see this in the code:
>
> r->allowed |= (1 << M_GET);
> r->allowed |= (1 << M_POST);
> if (r->method_number != M_GET && r->method_number != M_POST) {
> retval = DECLINED;
> goto sendcleanup;
> }
M_HEAD is not defined in apache includes.
/* Methods recognized (but not necessarily handled) by the server.
* These constants are used in bit shifting masks of size int, so it is
* unsafe to have more methods than bits in an int. HEAD == M_GET.
*/
is noticed there.
But the behaviour of GET and HEAD is definitely different.
> You could try adding M_HEAD in there, and see if that fixes things.
> I'll try myself when I get a free moment...
No wonder it fails to compile.
--
DtZ (homepage:http://xepb.ru/dtz ,ICQ UIN:5132840,Fido: 2:5020/730)
jabber://dreadbit@jabber.ru //HPG
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org
Re: HEAD request
Posted by "David N. Welton" <da...@dedasys.com>.
Dmitry the Zuryanovich wrote:
>Hello there,
>
> I have a directory with ErrorDocument 404 /feed/holder.rvt in .htaccess .
> When I get a GET request, holder.rvt is launched and works fine.
> But HEAD request gets 404 Not found response.
>
> Is it an apache problem or rivet-specific? What to do?
>
>
Looks as if it may indeed be a Rivet thing. I see this in the code:
r->allowed |= (1 << M_GET);
r->allowed |= (1 << M_POST);
if (r->method_number != M_GET && r->method_number != M_POST) {
retval = DECLINED;
goto sendcleanup;
}
You could try adding M_HEAD in there, and see if that fixes things.
I'll try myself when I get a free moment...
Ciao,
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org