Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to send a large message in POST request [Solved]

by nyx (Initiate)
on Jul 24, 2013 at 06:44 UTC ( [id://1046016]=perlquestion: print w/replies, xml ) Need Help??

nyx has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to send a large parameter (about 45000 characters) in a POST request, using LWP::UserAgent, but I get 400 Bad Request error. Sending the same request through a browser works fine.

Error message content:
<HTML> <HEAD><TITLE>Bad Request</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"> </HEAD> <BODY><h2>Bad Request - Request Too Long</h2> <hr><p>HTTP Error 400. The size of the request headers is too long.</p> </BODY></HTML>

Settings I used, without success:

  • call $browser->agent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0');
  • overwrite MaxLineLength and MaxHeaderLines values in Net::HTTP

How can I make this work?

Replies are listed 'Best First'.
Re: How to send a large message in POST request
by Anonymous Monk on Jul 24, 2013 at 06:48 UTC

    How can I make this work?

    Figure out what the difference is between what your browser sends and what your program (a browser) sends, then adjust your program to compensate

Re: How to send a large message in POST request
by mtmcc (Hermit) on Jul 24, 2013 at 07:18 UTC
    This might be helpful.

      Thanks for the idea, it solved my problem :) I don't really understand how, because LWP::UserAgent uses HTTP::Request::Common, and it didn't work.

        Thanks for letting me know... It's nice to know when suggestions turn out to be useful.

        All the best

Re: How to send a large message in POST request
by rnewsham (Curate) on Jul 24, 2013 at 07:49 UTC

    Without example code or data it is difficult to say what is happening. Have you checked that you are encoding or escaping the data you are sending correctly. Sending 45000 characters to me says there is a good chance you have something in there that invaldiates the request.

Re: How to send a large message in POST request
by hippo (Bishop) on Jul 24, 2013 at 12:07 UTC

    Since the error as stated is The size of the request headers is too long, chances are that you are sending your data in the headers instead of the body. Since you haven't shown your code, the guesses stop here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1046016]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2024-03-29 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found