Skip Menu |

This queue is for tickets about the POE-Component-Server-REST CPAN distribution.

Report information
The Basics
Id: 68826
Status: open
Priority: 0/
Queue: POE-Component-Server-REST

People
Owner: cpan.helba [...] recursor.net
Requestors: markus.jansen [...] ericsson.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.06
Fixed in: 1.07



CC: Markus Jansen <markus.jansen [...] ericsson.com>
Subject: POE::Component::Server::REST 1.03: Extracted key is always empty
Date: Wed, 15 Jun 2011 11:15:56 +0200
To: "bug-POE-Component-Server-REST [...] rt.cpan.org" <bug-POE-Component-Server-REST [...] rt.cpan.org>
From: Markus Jansen <markus.jansen [...] ericsson.com>
Hello Jean, I think I have found a defect in POE::Component::Server::REST 1.03; I simply cannot get a key argument extracted from a URL. The attached patch works (main change in the "unless" line, the others are just a sort of hardening ...). It would be great if you could consider the patch with Component::Server::REST 1.04 (or tell me what I am doing wrong). Best regards, Markus Jansen diff -c /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm perl5/POE/Component/Server *** /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm Sat Jun 11 15:52:40 2011 --- perl5/POE/Component/Server/REST.pm Wed Jun 15 11:11:21 2011 *************** *** 547,553 **** # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! unless ( $uri =~ /(\/\D+)(\/\w+)?(\/)?(\?session=(.+))?$/ ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } --- 547,553 ---- # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! unless ( $uri =~ /(\/\D+?)(\/\w+)?(\/)?(\?w+=(.+))?$/ ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } *************** *** 557,564 **** my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s/\/$//; ! $restkey =~ s/^\///; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; --- 557,564 ---- my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s,/+$,,; ! $restkey =~ s,^/+,,; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; Markus Jansen Ericsson GmbH Eurolab R&D Ericsson Allee 1 52134 Herzogenrath, Germany Phone +49 2407 575 5157 Fax +49 22407 575 150 Mobile +49 172 2742003 markus.jansen@ericsson.com www.ericsson.com Ericsson GmbH. Sitz: Düsseldorf. Registergericht: Amtsgericht Düsseldorf, HRB 33012. Geschäftsführer: Stefan Koetz (Vors.), Nils de Baar, Bernd Schmidt. Aufsichtsratsvorsitzender: Anders Runevad. This Communication is confidential. We only send and receive email on the basis of the terms set out at www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>.
Picture (Metafile) 1.jpg
Picture (Metafile) 2.jpg
CC: Markus Jansen <markus.jansen [...] ericsson.com>
Subject: RE: [rt.cpan.org #68826] AutoReply: POE::Component::Server::REST 1.03: Extracted key is always empty
Date: Wed, 15 Jun 2011 19:08:52 +0200
To: "bug-POE-Component-Server-REST [...] rt.cpan.org" <bug-POE-Component-Server-REST [...] rt.cpan.org>
From: Markus Jansen <markus.jansen [...] ericsson.com>
Hi again, below is an improved path, which works especially when extending the query via parameters to the URL. Best regards, Markus diff -c /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm perl5/POE/Component/Server *** /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm Sat Jun 11 15:52:40 2011 --- perl5/POE/Component/Server/REST.pm Wed Jun 15 19:06:23 2011 *************** *** 547,553 **** # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! unless ( $uri =~ /(\/\D+)(\/\w+)?(\/)?(\?session=(.+))?$/ ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } --- 547,555 ---- # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! my $uri_params = ''; ! ( $uri, $uri_params ) = ( $1, $2 ) if ( $uri =~ m,^(.+?)\?(.*)$,s ); ! unless ( $uri =~ m,(/\D+?)(/\w+)?(/)?$,s ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } *************** *** 557,564 **** my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s/\/$//; ! $restkey =~ s/^\///; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; --- 559,566 ---- my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s,/+$,,; ! $restkey =~ s,^/+,,; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; Show quoted text
-----Original Message----- From: Bugs in POE-Component-Server-REST via RT [mailto:bug-POE-Component-Server-REST@rt.cpan.org] Sent: Wednesday, June 15, 2011 11:16 AM To: Markus Jansen Subject: [rt.cpan.org #68826] AutoReply: POE::Component::Server::REST 1.03: Extracted key is always empty Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding: "POE::Component::Server::REST 1.03: Extracted key is always empty", a summary of which appears below. There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #68826]. Your ticket is accessible on the web at: https://rt.cpan.org/Ticket/Display.html?id=68826 Please include the string: [rt.cpan.org #68826] in the subject line of all future correspondence about this issue. To do so, you may reply to this message. Thank you, bug-POE-Component-Server-REST@rt.cpan.org ------------------------------------------------------------------------- Hello Jean, I think I have found a defect in POE::Component::Server::REST 1.03; I simply cannot get a key argument extracted from a URL. The attached patch works (main change in the "unless" line, the others are just a sort of hardening ...). It would be great if you could consider the patch with Component::Server::REST 1.04 (or tell me what I am doing wrong). Best regards, Markus Jansen diff -c /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm perl5/POE/Component/Server *** /vobs/cc/CCA-perl01/perl5____________________sixtyfive_char_path/prod/lib/site_perl/5.10.1/POE/Component/Server/REST.pm Sat Jun 11 15:52:40 2011 --- perl5/POE/Component/Server/REST.pm Wed Jun 15 11:11:21 2011 *************** *** 547,553 **** # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! unless ( $uri =~ /(\/\D+)(\/\w+)?(\/)?(\?session=(.+))?$/ ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } --- 547,553 ---- # Get the method name my $uri = $request->uri; debug(" requested uri: $uri"); ! unless ( $uri =~ /(\/\D+?)(\/\w+)?(\/)?(\?w+=(.+))?$/ ) { $kernel->yield( 'FAULT', $response, CLIENT_BADREQUEST, 'Bad Request', "Unrecognized REST url structure: $uri", ); return; } *************** *** 557,564 **** my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s/\/$//; ! $restkey =~ s/^\///; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; --- 557,564 ---- my $restkey = $2 || ''; # Remove trailing slash ! $method =~ s,/+$,,; ! $restkey =~ s,^/+,,; # Add prefx with given HTTP request method eg. PUT/foo/baz/bar $method = "$type$method"; Markus Jansen Ericsson GmbH Eurolab R&D Ericsson Allee 1 52134 Herzogenrath, Germany Phone +49 2407 575 5157 Fax +49 22407 575 150 Mobile +49 172 2742003 markus.jansen@ericsson.com www.ericsson.com Ericsson GmbH. Sitz: Düsseldorf. Registergericht: Amtsgericht Düsseldorf, HRB 33012. Geschäftsführer: Stefan Koetz (Vors.), Nils de Baar, Bernd Schmidt. Aufsichtsratsvorsitzender: Anders Runevad. This Communication is confidential. We only send and receive email on the basis of the terms set out at www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>.
Hi Markus, Thanks for the report and patches. I'll have a look at it. The URL extraction regex is currently not so smart. In order to get rid of the ?session parameter and the mess resulting from it. I'll rework the url to be in form of /<session>/<resources>/<key> which would look like the following for a session called 'infoservice' with registered method GET/country/town triggered with a key '123': GET /infoservice/country/town/123 - that should simplify extracting the key alot.
Hi Markus, I've implemented a far more sane service/resources/key extraction version in 1.06 which is currently beeing deployed on CPAN directories. Feel free to test it and tell me if it solved your problem.
On Sun Jun 19 13:48:24 2011, JSTEBENS wrote: Show quoted text
> Hi Markus, > > I've implemented a far more sane service/resources/key extraction > version in 1.06 which is currently beeing deployed on CPAN directories. > > Feel free to test it and tell me if it solved your problem.
For a concrete example, please see the examples/server.pl file - worked perfectly for me :)
CC: Markus Jansen <markus.jansen [...] ericsson.com>
Subject: RE: [rt.cpan.org #68826] POE::Component::Server::REST 1.03: Extracted key is always empty
Date: Mon, 20 Jun 2011 15:34:14 +0200
To: "bug-POE-Component-Server-REST [...] rt.cpan.org" <bug-POE-Component-Server-REST [...] rt.cpan.org>
From: Markus Jansen <markus.jansen [...] ericsson.com>
Hi Jean, version 1.06 has some great improvements. Unfortunately, I still fail to get non-numeric arguments sorted out: The following pattern applies (registered myservice/mymethod): URL method argument .../myservice/mymethod/123 mymethod 123 .../myservice/mymethod/ABC mymethod/ABC <empty> .../myservice/mymethod/ABC/123 mymethod/ABC 123 .../myservice/mymethod/2011/06 mymethod/2011 06 whereas I would expect: URL method argument .../myservice/mymethod/123 mymethod 123 .../myservice/mymethod/ABC mymethod ABC .../myservice/mymethod/ABC/123 mymethod ABC/123 .../myservice/mymethod/2011/06 mymethod 2011/06 It basically boils down whether IDs are strictly numerical, and whether to place hierarcies on the method side of life, or support them in the argument (2011/06 should be valid arguments). The most elegent and general way would be to adapt the extraction according to the methods registered. Best regards, Markus Show quoted text
-----Original Message----- From: Jean Stebens via RT [mailto:bug-POE-Component-Server-REST@rt.cpan.org] Sent: Sunday, June 19, 2011 7:50 PM To: Markus Jansen Subject: [rt.cpan.org #68826] POE::Component::Server::REST 1.03: Extracted key is always empty <URL: https://rt.cpan.org/Ticket/Display.html?id=68826 > On Sun Jun 19 13:48:24 2011, JSTEBENS wrote:
> Hi Markus, > > I've implemented a far more sane service/resources/key extraction > version in 1.06 which is currently beeing deployed on CPAN directories. > > Feel free to test it and tell me if it solved your problem.
For a concrete example, please see the examples/server.pl file - worked perfectly for me :)
On Mon Jun 20 15:34:28 2011, markus.jansen@ericsson.com wrote: Show quoted text
> whereas I would expect: > > URL method argument: >.../myservice/mymethod/123 mymethod 123 >.../myservice/mymethod/ABC mymethod ABC >.../myservice/mymethod/ABC/123 mymethod ABC/123 >.../myservice/mymethod/2011/06 mymethod 2011/06
Show quoted text
> > It basically boils down whether IDs are strictly numerical, and > whether to place hierarcies > on the method side of life, or support them in the argument (2011/06 > should be valid arguments).
Correct - in my understanding KEYs should always be numerical, or at heaviest some hexadecimal representation. Thats why the service only sets the key when they are numerical. The design of 1.06 actually implies that for each hierarchical resource you need a method. This simplifies the binding of methods for resources - else the service would need to hold some kind of hierarchical method information, which would be a bit heavier - I've love to keep it simple. But nevertheless I can understand the way it should be - I'll try to come up with a decent solution in the next weeks, which allows paths to be part of keys. Thanks for the hint, Jean
Hi Markus, There is a first implementation available at: https://github.com/jstebens/POE-Component-Server-REST Feel free to test it - worked for the example server. The drawbacks: 1) Obligatory to delete the published paths/method relations in a hierarchical correct order. ie. the server wont allow deletion of a path/method relation if other path/method relations are still below it. Show quoted text
> delete /foo/baz/bar [ok] > delete /foo/baz [ok]
Show quoted text
> delete /foo/baz [FAIL - cause bar is still active] > delete /foo/baz/bar [ok]
2) Reduced speed because of tree parsing. Methods arent only verified accourding to their tree entry, but also against a simply list called INTERFACES. Cheers, Jean
Fixed some last bugs and cleaned up code with method hierarchy in commit b9d75dc9a1fcdb13b750d11ff50e463e45a6592e - feel free to check it out and play with.
All fixed in 1.08 - please have a look and do a review based on the latest version - thanks.
CC: Markus Jansen <markus.jansen [...] ericsson.com>
Subject: RE: [rt.cpan.org #68826] POE::Component::Server::REST 1.03: Extracted key is always empty
Date: Tue, 28 Jun 2011 16:14:29 +0200
To: "bug-POE-Component-Server-REST [...] rt.cpan.org" <bug-POE-Component-Server-REST [...] rt.cpan.org>
From: Markus Jansen <markus.jansen [...] ericsson.com>
Hello Jean, sorry for the late reply, and thanks for the great work on your side! Everything seems to work pretty well. I already started testing the github code, but then got hit by a reliability problem which fortunately had nothing to do with POE and your code (far too old Solaris 10 tcp/kernel patch), and after that I got fully occupied by another task ... Best regards, Markus Show quoted text
-----Original Message----- From: Jean via RT [mailto:bug-POE-Component-Server-REST@rt.cpan.org] Sent: Saturday, June 25, 2011 2:59 PM To: Markus Jansen Subject: [rt.cpan.org #68826] POE::Component::Server::REST 1.03: Extracted key is always empty <URL: https://rt.cpan.org/Ticket/Display.html?id=68826 > All fixed in 1.08 - please have a look and do a review based on the latest version - thanks.
On Tue Jun 28 19:52:48 2011, markus.jansen@ericsson.com wrote: Show quoted text
> Hello Jean, > > sorry for the late reply, and thanks for the great work on your side! > Everything seems to work pretty well. > I already started testing the github code, but then got hit by a > reliability problem > which fortunately had nothing to do with POE and your code (far too > old Solaris 10 tcp/kernel patch), > and after that I got fully occupied by another task ...
I'd appreciate a realistic rating from you on the current version and overfall approach (you know the little 0 to 5 stars on cpan module overview) - thanks!