Re: PoCo::Client::HTTP Bug

2005-09-05 Thread Rocco Caputo

On May 5, 2005, at 16:23, Tim Cheadle wrote:


On Thu, 2005-05-05 at 10:48 -0400, Tim Cheadle wrote:


Any reason not to do this for other methods as well?


Because the other methods in HTTP 1.0 (GET and HEAD) don't  
require it,

nor does it make sense as they don't have any post-header content to
send.


Right, but there's methods in 1.1 (for which Client::HTTP is being
rewritten) that can have content (e.g. PROPFIND). So why not just add
a content-length header whenever there is content?


Per the PoCo::Client::HTTP perldoc:

BUGS
   HTTP/1.1 requests are not supported.


This bug has been fixed.  Unfortunately it invalidates your patch.  I  
would still like the component to do the right thing, but I don't  
know enough about the various HTTP protocol versions to say what that  
might be.


If you'd like to resubmit your patch for POE::Component::Client::HTTP  
at its current revision, I would be happy to apply it.


--
Rocco Caputo - http://poe.perl.org/


Re: PoCo::Client::HTTP Bug

2005-05-06 Thread Tim Cheadle
> Surely if someone is using chunks you don't want to use content-length?

HTTP 1.0 does not support OPTIONS (and therefore chunks) requests.



Re: PoCo::Client::HTTP Bug

2005-05-06 Thread Arthur Bergman
On 6 May 2005, at 05:30, Tim Cheadle wrote:
I suppose it wouldn't hurt anything to simply add a Content-Length 
header
to every request (including those with zero-length content) if no such
header exists already.  Any HTTPd that blows up when it sees
Content-Length=0 on a GET request is buggy to begin with. =)

If there is zero-length content, we should still add Content-Length=0.
Tim
Surely if someone is using chunks you don't want to use content-length?
Cheers
Arthur
-
CTO @ Fotango Ltd
+447834716919
http://www.fotango.com/

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


Re: PoCo::Client::HTTP Bug

2005-05-06 Thread Tim Cheadle
> How about:
>
>   If there's nonzero-length content
> And there isn't a Content-Length header
>   We go ahead and add one?
>
> Would that cause damage anywhere?
> If so, is there an alternate solution that would cause less (ideally
> no) damage?

I suppose it wouldn't hurt anything to simply add a Content-Length header
to every request (including those with zero-length content) if no such
header exists already.  Any HTTPd that blows up when it sees
Content-Length=0 on a GET request is buggy to begin with. =)

If there is zero-length content, we should still add Content-Length=0.

Tim



Re: PoCo::Client::HTTP Bug

2005-05-05 Thread Rocco Caputo
On Thu, May 05, 2005 at 10:48:58AM -0400, Tim Cheadle wrote:
> > Any reason not to do this for other methods as well?
> 
> Because the other methods in HTTP 1.0 (GET and HEAD) don't require it, nor
> does it make sense as they don't have any post-header content to send.

How about:

  If there's nonzero-length content
And there isn't a Content-Length header
  We go ahead and add one?

Would that cause damage anywhere?
If so, is there an alternate solution that would cause less (ideally
no) damage?

-- 
Rocco Caputo - http://poe.perl.org/


Re: PoCo::Client::HTTP Bug

2005-05-05 Thread Tim Cheadle
> On Thu, 2005-05-05 at 10:48 -0400, Tim Cheadle wrote:
>> > Any reason not to do this for other methods as well?
>>
>> Because the other methods in HTTP 1.0 (GET and HEAD) don't require it,
>> nor
>> does it make sense as they don't have any post-header content to send.
>>
> Right, but there's methods in 1.1 (for which Client::HTTP is being
> rewritten) that can have content (e.g. PROPFIND). So why not just add
> a content-length header whenever there is content?

Per the PoCo::Client::HTTP perldoc:

BUGS
   HTTP/1.1 requests are not supported.



Re: PoCo::Client::HTTP Bug

2005-05-05 Thread Tim Cheadle
> Any reason not to do this for other methods as well?

Because the other methods in HTTP 1.0 (GET and HEAD) don't require it, nor
does it make sense as they don't have any post-header content to send.



Re: PoCo::Client::HTTP Bug

2005-05-04 Thread Mathieu Longtin
All I know is I had this issue with Poco::Server::HTTP. So
when I see automated content measurement, I'd rather have
them fixed in the library.

--- Arthur Bergman <[EMAIL PROTECTED]> wrote:
> 
> 
> On 4 May 2005, at 22:04, Matt Cashner wrote:
> 
> > On Wed, 2005-05-04 at 13:40 -0700, Mathieu Longtin
> wrote:
> >> Actually, you should do a use bytes before you
> calculate
> >> the length. Otherwise, unicode strings will get the
> number
> >> of characters, not bytes, and send the wrong length.
> >
> > poe itself does a use bytes on startup so doing that
> again here is not
> > necessary.
> >
> > --
> > sungo
> >
> >
> 
> surely it is lexically scoped, is it not?
> 
> -
> CTO @ Fotango Ltd
> +447834716919
> http://www.fotango.com/
> 
> 



Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html



Re: PoCo::Client::HTTP Bug

2005-05-04 Thread Martijn van Beers
On Wed, 2005-05-04 at 16:33 -0400, Tim Cheadle wrote:
> --- HTTP.pm.old 2005-05-04 16:31:57.600035522 -0400
> +++ HTTP.pm 2005-05-04 16:32:02.713339216 -0400
> @@ -344,15 +344,6 @@
>);
>}
> 
> -  # Add a Content-Length header for POSTs
> -  if (defined $http_request->method() and $http_request->method() eq
> 'POST') {

Any reason not to do this for other methods as well?


Martijn



Re: PoCo::Client::HTTP Bug

2005-05-04 Thread Arthur Bergman

On 4 May 2005, at 22:04, Matt Cashner wrote:
On Wed, 2005-05-04 at 13:40 -0700, Mathieu Longtin wrote:
Actually, you should do a use bytes before you calculate
the length. Otherwise, unicode strings will get the number
of characters, not bytes, and send the wrong length.
poe itself does a use bytes on startup so doing that again here is not
necessary.
--
sungo

surely it is lexically scoped, is it not?
-
CTO @ Fotango Ltd
+447834716919
http://www.fotango.com/


Re: PoCo::Client::HTTP Bug

2005-05-04 Thread Matt Cashner
On Wed, 2005-05-04 at 13:40 -0700, Mathieu Longtin wrote:
> Actually, you should do a use bytes before you calculate
> the length. Otherwise, unicode strings will get the number
> of characters, not bytes, and send the wrong length.

poe itself does a use bytes on startup so doing that again here is not
necessary.

--
sungo



Re: PoCo::Client::HTTP Bug

2005-05-04 Thread Mathieu Longtin
Actually, you should do a use bytes before you calculate
the length. Otherwise, unicode strings will get the number
of characters, not bytes, and send the wrong length.

--- Tim Cheadle <[EMAIL PROTECTED]> wrote:
> I'm trying to use POE::Component::Client::HTTP for
> asynchronous POST
> requests, and it has a fatal bug that breaks such
> requests.  As per the
> HTTP 1.0 spec, all POSTs are required to have a
> "Content-Length" header
> specifying the number of octets in the content of the
> request.  The POE
> component does not automatically set this header if not
> previously
> present.
> 
> This results in servers not knowing when the request is
> complete.
> 
> If you add the Content-Length header, things work great.
> 
> Tim
> 
> 
> Here is a simple patch:
> 
> --- HTTP.pm.old 2005-05-04 16:31:57.600035522 -0400
> +++ HTTP.pm 2005-05-04 16:32:02.713339216 -0400
> @@ -344,15 +344,6 @@
>);
>}
> 
> -  # Add a Content-Length header for POSTs
> -  if (defined $http_request->method() and
> $http_request->method() eq
> 'POST') {
> -if (defined $http_request->content()) {
> -  $http_request->header(
> -'Content-Length' =>
> length($http_request->content())
> -  );
> -}
> -  }
> -
># Create a progress postback if requested.
>my $progress_postback;
>$progress_postback =
> $sender->postback($progress_event, $http_request,
> $tag)
> 
> 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


PoCo::Client::HTTP Bug

2005-05-04 Thread Tim Cheadle
I'm trying to use POE::Component::Client::HTTP for asynchronous POST
requests, and it has a fatal bug that breaks such requests.  As per the
HTTP 1.0 spec, all POSTs are required to have a "Content-Length" header
specifying the number of octets in the content of the request.  The POE
component does not automatically set this header if not previously
present.

This results in servers not knowing when the request is complete.

If you add the Content-Length header, things work great.

Tim


Here is a simple patch:

--- HTTP.pm.old 2005-05-04 16:31:57.600035522 -0400
+++ HTTP.pm 2005-05-04 16:32:02.713339216 -0400
@@ -344,15 +344,6 @@
   );
   }

-  # Add a Content-Length header for POSTs
-  if (defined $http_request->method() and $http_request->method() eq
'POST') {
-if (defined $http_request->content()) {
-  $http_request->header(
-'Content-Length' => length($http_request->content())
-  );
-}
-  }
-
   # Create a progress postback if requested.
   my $progress_postback;
   $progress_postback = $sender->postback($progress_event, $http_request,
$tag)