in reply to Undeleteable header in WWW::Mechanize

I've started looking into this.

1) It's not WWW::Mechanize adding that header.

And even if it was,

2) The last thing WWW::Mechanize does before passing the request on to the underlying library is to process add_header directives, so $mech->add_header( TE => undef); would work if it was WWW::Mechanize adding that header.

I'm off to check if it's something in libwww-perl, or it if it's an external source (such as a proxy).

Replies are listed 'Best First'.
Re^2: Undeleteable header in WWW::Mechanize
by ikegami (Patriarch) on Dec 19, 2007 at 22:17 UTC

    It took some searching, but I found that it's added by Net::HTTP at the request of LWP::Protocol::http. You can change the default by using

    @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( SendTE => 0, );

    You can use local to limit the scope of the change if you desire.

    { local @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( SendTE => 0, ); ...do the request... }

    Untested.

      works like a charm.
      I feel pretty stupid now, that'd have been the last place I would have looked. That also fixed an issue with the Connection header being set to "keep-alive, close" since it's possible to set a proper Keep-Alive header like this:
      local @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( SendTE => 0, KeepAlive => 1 );

      Thank You!