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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 949
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-16573-1155839052-1372.21051-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: BOOK [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 1673
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
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-16573-1155839052-1372.21051-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-16592-1155847963-632.21051-0-0 [...] rt.cpan.org>
References: <rt-3.6.HEAD-16573-1155839052-1372.21051-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 534
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!
MIME-Version: 1.0 (Apple Message framework v752.2)
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.6.HEAD-16573-1155839052-1372.21051-6-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.752.2)
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-21051 [...] rt.cpan.org> <rt-3.6.HEAD-16573-1155839052-1372.21051-6-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"; delsp="yes"; format="flowed"
X-RT-Original-Encoding: US-ASCII
Received: from la.mx.develooper.com (ss1.fabel.dk [63.251.223.179]) by diesel.bestpractical.com (Postfix) with SMTP id 647AA4D803F for <bug-HTTP-Proxy [...] rt.cpan.org>; Thu, 17 Aug 2006 18:25:00 -0400 (EDT)
Received: (qmail 13997 invoked by alias); 17 Aug 2006 22:24:59 -0000
Received: from smtp.clotho.com (HELO atlas.clotho.com) (66.170.16.61) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 17 Aug 2006 15:24:52 -0700
Received: from [127.0.0.1] (unknown [66.170.16.61]) by atlas.clotho.com (Postfix) with ESMTP id 8952927B2333D for <bug-HTTP-Proxy [...] rt.cpan.org>; Thu, 17 Aug 2006 17:27:38 -0500 (CDT)
Delivered-To: cpan-bug+http-proxy [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #21051] Need a way to not clear Content-Length
Return-Path: <chris [...] clotho.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: bug-HTTP-Proxy [...] rt.cpan.org
Date: Thu, 17 Aug 2006 17:24:45 -0500
Message-Id: <387FBC60-FC0D-4182-BAA4-8DBC3AFE9C1F [...] clotho.com>
To: bug-HTTP-Proxy [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Chris Dolan <chris [...] clotho.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-16592-1155853506-1258.21051-0-0 [...] rt.cpan.org>
Content-Length: 2365
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/)
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-16592-1155853506-1258.21051-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-16544-1155857369-505.21051-0-0 [...] rt.cpan.org>
References: <RT-Ticket-21051 [...] rt.cpan.org> <rt-3.6.HEAD-16573-1155839052-1372.21051-6-0 [...] rt.cpan.org> <387FBC60-FC0D-4182-BAA4-8DBC3AFE9C1F [...] clotho.com> <rt-3.6.HEAD-16592-1155853506-1258.21051-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 346
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
X-Source:
MIME-Version: 1.0 (Apple Message framework v752.2)
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.6.HEAD-16544-1155857369-505.21051-6-0 [...] rt.cpan.org>
X-Source-Args:
X-Mailer: Apple Mail (2.752.2)
X-Source-Dir:
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-21051 [...] rt.cpan.org> <rt-3.6.HEAD-16573-1155839052-1372.21051-6-0 [...] rt.cpan.org> <387FBC60-FC0D-4182-BAA4-8DBC3AFE9C1F [...] clotho.com> <rt-3.6.HEAD-16592-1155853506-1258.21051-6-0 [...] rt.cpan.org> <rt-3.6.HEAD-16544-1155857369-505.21051-6-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"; delsp="yes"; format="flowed"
X-Antiabuse: This header was added to track abuse, please include it with any abuse report
X-Antiabuse: Primary Hostname - central.dnspropagation.com
X-Antiabuse: Original Domain - rt.cpan.org
X-Antiabuse: Originator/Caller UID/GID - [0 0] / [47 12]
X-Antiabuse: Sender Address Domain - chrisdolan.net
X-RT-Original-Encoding: US-ASCII
Received: from la.mx.develooper.com (ss1.fabel.dk [63.251.223.179]) by diesel.bestpractical.com (Postfix) with SMTP id 9A18A4D803F for <bug-HTTP-Proxy [...] rt.cpan.org>; Thu, 17 Aug 2006 20:55:37 -0400 (EDT)
Received: (qmail 4646 invoked by alias); 18 Aug 2006 00:55:36 -0000
Received: from central.dnspropagation.com (HELO central.dnspropagation.com) (147.202.43.96) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 17 Aug 2006 17:55:34 -0700
Received: from smtp.clotho.com ([66.170.16.61] helo=[127.0.0.1]) by central.dnspropagation.com with esmtpa (Exim 4.52) id 1GDse3-0003WR-Dq for bug-HTTP-Proxy [...] rt.cpan.org; Thu, 17 Aug 2006 19:55:31 -0500
Delivered-To: cpan-bug+http-proxy [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #21051] Need a way to not clear Content-Length
Return-Path: <chris [...] chrisdolan.net>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: bug-HTTP-Proxy [...] rt.cpan.org
Date: Thu, 17 Aug 2006 19:55:21 -0500
Message-Id: <D9EBC292-F89E-43E9-A52C-AE2645F193F4 [...] chrisdolan.net>
To: bug-HTTP-Proxy [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Chris Dolan <chris [...] chrisdolan.net>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-16592-1155862541-1017.21051-0-0 [...] rt.cpan.org>
Content-Length: 696
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.