PUT handler
am 24.04.2009 15:51:29 von aw
Greetings.
I would like to create a mod_perl PUT handler, but I don't really
understand if I have for that to do anything special in the handler()
method (apart from dealing with the PUT data itself).
Is there an example somewhere ?
In particular, I don't understand this page :
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_allowed_
Does that mean that I have to tell Apacher somehow in advance that I do
accept PUT requests, or does it mean the opposite ?
Thanks.
Re: PUT handler
am 24.04.2009 16:22:39 von ELINTPimp
Hello,
You do not have to 'tell' apache your going to do anything...in fact, =20=
there are no mechanisms or reasons to do something like that with the =20=
mod_perl architecture. You simply handle the request as you want to...
There are some stipulations handling PUT requests, if you read it =20
directly from stream you can only do it once, for example. Ensure you =20=
read the mod_perl docs on it and try it out.
Ps. If you find the dogs cryptic, feel free to share your experience =20
through blogs or documentation contributions!
Thanks,
S
On Apr 24, 2009, at 6:51 AM, André Warnier wrote:
> Greetings.
>
> I would like to create a mod_perl PUT handler, but I don't really =20
> understand if I have for that to do anything special in the =20
> handler() method (apart from dealing with the PUT data itself).
> Is there an example somewhere ?
>
> In particular, I don't understand this page :
> http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_allowed_
>
> Does that mean that I have to tell Apacher somehow in advance that I =20=
> do accept PUT requests, or does it mean the opposite ?
>
> Thanks.
Re: PUT handler
am 24.04.2009 16:39:24 von aw
Thanks.
Do you happen to know /where/ in the on-line mod_perl docs there is
information about handling a PUT request.
(I found a nice article in German on the web, here :
http://www.farid-hajji.net/books/de/Hajji_Farid/pbv2/ew/cgi- upload.html
)
Searching for "+mod_perl +"put handler" gives some interesting
historical material..
Steve Siebert wrote:
> Hello,
>
> You do not have to 'tell' apache your going to do anything...in fact,
> there are no mechanisms or reasons to do something like that with the
> mod_perl architecture. You simply handle the request as you want to...
>
> There are some stipulations handling PUT requests, if you read it
> directly from stream you can only do it once, for example. Ensure you
> read the mod_perl docs on it and try it out.
>
> Ps. If you find the dogs cryptic, feel free to share your experience
> through blogs or documentation contributions!
>
Re: PUT handler
am 24.04.2009 17:12:57 von Adam Prime
André Warnier wrote:
> Thanks.
> Do you happen to know /where/ in the on-line mod_perl docs there is
> information about handling a PUT request.
> (I found a nice article in German on the web, here :
> http://www.farid-hajji.net/books/de/Hajji_Farid/pbv2/ew/cgi- upload.html
> )
> Searching for "+mod_perl +"put handler" gives some interesting
> historical material..
I don't think i've ever seen anything about PUT requests directly, but
i'd imagine you'd just do something like (completely untested):
sub handler :method {
my ($self,$r) = @_;
if ($r->method eq 'PUT') {
return $self->handle_put($r);
}
return DECLINED; #or whatever
}
sub handle_put {
my ($self,$r) = @_;
# read the content with $r->read and the content-length header
# do whatever you want to do with the content of the put request.
return OK;
}
Using a handler anyway.
Adam
Re: PUT handler
am 24.04.2009 17:25:56 von aw
Thanks.
That is pretty much what I've seen so far in my browsing.
I was just feeling uneasy because it looks somewhat /too/ simple.
For a special problem, I have to "disguise" a multi-part POST request
from a client into a PUT request, and handle it as such on the server.
It's an interesting problem, but I feel a bit uneasy about it, don't
know why really.
Adam Prime wrote:
> André Warnier wrote:
>> Thanks.
>> Do you happen to know /where/ in the on-line mod_perl docs there is
>> information about handling a PUT request.
>> (I found a nice article in German on the web, here :
>> http://www.farid-hajji.net/books/de/Hajji_Farid/pbv2/ew/cgi- upload.html
>> )
>> Searching for "+mod_perl +"put handler" gives some interesting
>> historical material..
>
> I don't think i've ever seen anything about PUT requests directly, but
> i'd imagine you'd just do something like (completely untested):
>
> sub handler :method {
> my ($self,$r) = @_;
> if ($r->method eq 'PUT') {
> return $self->handle_put($r);
> }
> return DECLINED; #or whatever
> }
>
> sub handle_put {
> my ($self,$r) = @_;
>
> # read the content with $r->read and the content-length header
>
> # do whatever you want to do with the content of the put request.
>
> return OK;
> }
>
> Using a handler anyway.
>
> Adam
>