Skip Menu |
 

This queue is for tickets about the HTTP-Proxy CPAN distribution.

Report information
The Basics
Id: 21051
Status: resolved
Priority: 0/
Queue: HTTP-Proxy

People
Owner: Nobody in particular
Requestors: cpan [...] clotho.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.19
Fixed in: 0.20



Subject: Need a way to not clear Content-Length
Download (untitled) / with headers
text/plain 949b
I have created a filter that throttles bandwidth by postponing delivery of content (useful for simulating a slow connection). Because I'm postponing content, the HTTP headers get sent before the end of content, so the H::P::FilterStack::active function returns true, and the Content-Length gets cleared. I understand why this happens (erroneous Content-Length is worse than none at all), but I'd like a way to tell HTTP::Proxy that I'm not planning to alter the content in any way and that the Content-Length can be passed through verbatim. As a workaround, I'm currently doing this in my proxy program: BEGIN { no warnings; *HTTP::Proxy::FilterStack::active = sub { return 0; }; } But of course that's evil. Instead, I think a better solution would be that the BodyFilter subclasses should indicate whether they will alter the content or not. If any say true, then clear the Content-Length if active. Otherwise, leave it as-is.
From: BOOK [...] cpan.org
Download (untitled) / with headers
text/plain 1.6k
On Thu Aug 17 14:10:15 2006, CLOTHO wrote: Show quoted text
> I have created a filter that throttles bandwidth by postponing delivery > of content (useful for simulating a slow connection). Because I'm > postponing content, the HTTP headers get sent before the end of content, > so the H::P::FilterStack::active function returns true, and the > Content-Length gets cleared.
Actually, active() returns true because the proxy has selected some filters to be applied on this response. Show quoted text
> I understand why this happens (erroneous Content-Length is worse than > none at all), but I'd like a way to tell HTTP::Proxy that I'm not > planning to alter the content in any way and that the Content-Length can > be passed through verbatim.
It's better than before, when I simply removed the Content-Length entirely. ;-) Show quoted text
> As a workaround, I'm currently doing this in my proxy program: > > BEGIN { > no warnings; > *HTTP::Proxy::FilterStack::active = sub { return 0; }; > } > > But of course that's evil. Instead, I think a better solution would be > that the BodyFilter subclasses should indicate whether they will alter > the content or not. If any say true, then clear the Content-Length if > active. Otherwise, leave it as-is.
Actually, since filters can be stacked, it would be safer to leave the Content-Length header unmodified only if *all* selected filters say they won't modify the data. I think one option would be to suppose that by default, Body filters do modify the data, and let one override the appropriate method. How would you name this HTTP::Proxy::BodyFilter method? I'm thinking about (?:does|can|may)_(?:modify|edit|alter) or something like that. -- BooK
Download (untitled) / with headers
text/plain 534b
On Thu Aug 17 14:24:12 2006, BOOK wrote: Show quoted text
> > How would you name this HTTP::Proxy::BodyFilter method? > I'm thinking about (?:does|can|may)_(?:modify|edit|alter) or > something like that.
I've settled on will_modify() for the moment. Please let me know if you find something better. I was quite happy to find out that four of the predefined filters will return a will_modify() value of 0: complete, save, lines and tags. The HPBF::simple class will support a special parameter to let you define this value. Thanks for your proposal!
Subject: Re: [rt.cpan.org #21051] Need a way to not clear Content-Length
Date: Thu, 17 Aug 2006 17:24:45 -0500
To: bug-HTTP-Proxy [...] rt.cpan.org
From: Chris Dolan <chris [...] clotho.com>
Download (untitled) / with headers
text/plain 2.3k
On Aug 17, 2006, at 1:24 PM, Philippe Bruhat via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=21051 > > > On Thu Aug 17 14:10:15 2006, CLOTHO wrote:
>> I have created a filter that throttles bandwidth by postponing >> delivery >> of content (useful for simulating a slow connection). Because I'm >> postponing content, the HTTP headers get sent before the end of >> content, >> so the H::P::FilterStack::active function returns true, and the >> Content-Length gets cleared.
> > Actually, active() returns true because the proxy has selected some > filters to be applied on this response.
Ahh, I guess I misunderstood. Show quoted text
>> I understand why this happens (erroneous Content-Length is worse than >> none at all), but I'd like a way to tell HTTP::Proxy that I'm not >> planning to alter the content in any way and that the Content- >> Length can >> be passed through verbatim.
> > It's better than before, when I simply removed the Content-Length > entirely. ;-)
:-) Show quoted text
>> As a workaround, I'm currently doing this in my proxy program: >> >> BEGIN { >> no warnings; >> *HTTP::Proxy::FilterStack::active = sub { return 0; }; >> } >> >> But of course that's evil. Instead, I think a better solution >> would be >> that the BodyFilter subclasses should indicate whether they will >> alter >> the content or not. If any say true, then clear the Content- >> Length if >> active. Otherwise, leave it as-is.
> > Actually, since filters can be stacked, it would be safer to leave the > Content-Length header unmodified only if *all* selected filters say > they won't modify the data.
Yes, we're saying the same thing. Show quoted text
> I think one option would be to suppose that by default, Body filters > do modify the data, and let one override the appropriate method.
Agreed. Show quoted text
> How would you name this HTTP::Proxy::BodyFilter method? > I'm thinking about (?:does|can|may)_(?:modify|edit|alter) or > something like that.
I like the will_modify you settled on in another email Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Download (untitled) / with headers
text/plain 346b
On Thu Aug 17 18:25:06 2006, chris@clotho.com wrote: Show quoted text
> > I like the will_modify you settled on in another email >
OK then. I'll publish version 0.20 ASAP. It's going to close this ticket and #20251, but not #13877 (although I promised it would, but I did not have the time to look at your patches. Sorry). Thanks for your patience. -- BooK
Subject: Re: [rt.cpan.org #21051] Need a way to not clear Content-Length
Date: Thu, 17 Aug 2006 19:55:21 -0500
To: bug-HTTP-Proxy [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
Download (untitled) / with headers
text/plain 696b
On Aug 17, 2006, at 6:29 PM, Philippe Bruhat via RT wrote: Show quoted text
> OK then. I'll publish version 0.20 ASAP. It's going to close this > ticket > and #20251, but not #13877 (although I promised it would, but I did > not > have the time to look at your patches. Sorry). > > Thanks for your patience.
Philippe, That sounds fine. In defense of #13877: it applies cleanly to 0.19 and has no significant feature changes. It's primarily a refactoring patch to simplify redundant code and make it easier to add features later. Chris -- Chris Dolan, Software Developer, http://www.chrisdolan.net/ Public key: http://www.chrisdolan.net/public.key vCard: http://www.chrisdolan.net/ChrisDolan.vcf


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.