Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^5: LWP 400 Bad Request on POST

by afoken (Abbot)
on Nov 14, 2013 at 18:05 UTC ( #1062632=note: print w/replies, xml ) Need Help??

in reply to Re^4: LWP 400 Bad Request on POST
in thread LWP 400 Bad Request on POST

First thing I noticed is that the browser is doing a CONNECT request, not a POST.

A browser issuing a CONNECT request is typical for access to a HTTPS URL (instead of a HTTP URL). CONNECT bypasses most of the proxy (especially the filter logic), so it is usually restricted. Typically you are only allowed to connect to the HTTPS standard port 443, and no other port.

When I switched to a CONNECT method in the script I immediately got a 200 return code. Still no content though.

You should not have to change your code from POST to CONNECT, in fact, this should not work. LWP::UserAgent should issue a CONNECT request to the proxy, make a SSL connection to the HTTPS server, and issue your POST request through the SSL encrypted connection. When you issue a CONNECT manually, the proxy just answers 200 OK and switches to forwarding all data between your script and the destination server.

If you can access HTTPS URLs from a browser through the proxy, LWP::UserAgent should be able to do so, too. Try something simple first, like a GET request for If that does not work, talk with the proxy admin, make him/her look into the proxy logfiles. Talk with the network admins, try to get a way out around the proxy (directly through the firewall).


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062632]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-06-24 19:21 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.