develooper Front page | perl.libwww | Postings from May 2015

Re: Is default Content-Type changed in a POST request?

Thread Previous
Octavian Rasnita
May 27, 2015 04:55
Re: Is default Content-Type changed in a POST request?
Message ID:
From: Gisle Aas 

  On Mon, May 25, 2015 at 7:46 PM, Octavian Rasnita <> wrote:


    I set 2 default headers using default_header() method and one of them is "Content-Type" which is set to "application/json", but it looks that it is overidden with "application/x-www-form-urlencoded" when doing a POST request. Is this intentionally?

  It's a consequence of how HTTP::Request::Common::POST() currently works; $ua->post() is just a thin wrapper for that function.  I guess POST() could have been changed to not set the "Content-Type" if passed scalar "Content".  It currently defaults to "application/x-www-form-urlencoded" which cause the outer default to not apply.  Changing this has the potential to break other code so it might be better to accept this behaviour.


  Thanks Gisle. So there are historical reasons.
  I will create another wrapper in my code that sets that default Content-Type just once.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About