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

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

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


  On Mon, May 25, 2015 at 7:46 PM, Octavian Rasnita <orasnita@gmail.com> wrote:

    Hello,

    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.


  Regards,
  Gisle



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

  --Octavian

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About