Le vendredi 28 novembre 2003 à 03:00, Gisle Aas écrivait:
> "Philippe 'BooK' Bruhat" <[EMAIL PROTECTED]> writes:
> 
> > So, in the end, I'm just pointing at this "problem", asking if it's a
> > bug or not.
> 
> I don't regard this as a bug.

Thanks for the clarification.

> If you don't want to risk ending up with multi-valued header fields
> joined by ", " just call the header() method in array context.  The
> joining is just a convenience feature.

In HTTP::Proxy, I want to separate hop-by-hop headers from end-to-end
headers, so that the proxy only forwards the end-to-end headers, but can
still do somthing with the hop-by-hop headers.

RFC 2616 says:

   HTTP/1.1 proxies MUST parse the Connection header field before a
   message is forwarded and, for each connection-token in this field,
   remove any header field(s) from the message with the same name as the
   connection-token. Connection options are signaled by the presence of
   a connection-token in the Connection header field, not by any
   corresponding additional header field(s), since the additional header
   field may not be sent if there are no parameters associated with that
   connection option.

It also says:

13.5.1 End-to-end and Hop-by-hop Headers

   For the purpose of defining the behavior of caches and non-caching
   proxies, we divide HTTP headers into two categories:

      - End-to-end headers, which are  transmitted to the ultimate
        recipient of a request or response. End-to-end headers in
        responses MUST be stored as part of a cache entry and MUST be
        transmitted in any response formed from a cache entry.

      - Hop-by-hop headers, which are meaningful only for a single
        transport-level connection, and are not stored by caches or
        forwarded by proxies.

   The following HTTP/1.1 headers are hop-by-hop headers:

      - Connection
      - Keep-Alive
      - Proxy-Authenticate
      - Proxy-Authorization
      - TE
      - Trailers
      - Transfer-Encoding
      - Upgrade

   All other headers defined by HTTP/1.1 are end-to-end headers.

   Other hop-by-hop headers MUST be listed in a Connection header,
   (section 14.10) to be introduced into HTTP/1.1 (or later).

So, should expect hop-by-hop headers to look like:

   Connection: Foo, Bar
   Foo: This is the foo hop-by-hop header
   Bar: This is the bar hop-by-hop header

or more like:

   Connection: Foo
   Foo: This is the foo hop-by-hop header
   Connection: Bar
   Bar: This is the bar hop-by-hop header

?

In the first case, this means that I cannot count on HTTP::Headers to
do the splitting for me in list context, but that I should split on
',' myself.

Is it ok for me to do something like the following:

    # hop-by-hop headers are set aside
    my $hop = HTTP::Headers->new();
    for ( qw( Connection Keep-Alive Proxy-Authenticate Proxy-Authorization 
        TE Trailers Transfer-Encoding Upgrade Proxy-Connection Public ) ) {
        if( $message->headers->header($_) ) {
            $hop->header( $_ => $message->headers->header($_) );
            $headers->remove_header($_);
        }
    }
    # new hop-by-hop headers (in the Connection: header)
    for (map { split /\s*,\s*/ } $hop->header( 'Connection' ) ) {
        if( $message->headers->header($_) ) {
            $hop->header( $_ => $message->headers->header($_) );
            $headers->remove_header($_);
        }
    }

(I found the Proxy-Connection and Public headers in RFC 2068, I think.)

-- 
 Philippe "BooK" Bruhat

 When you deal in weapons, there are no winners... only losers.
                                    (Moral from Groo The Wanderer #31 (Epic))

Reply via email to