Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:56:04+00:00 2026-06-10T05:56:04+00:00

For requests not sent by HTML forms, does HTTP limit the Content-Type of a

  • 0

For requests not sent by HTML forms, does HTTP limit the Content-Type of a request to application/x-www-form-urlencoded for non-file uploads, or is that MIME type “right”/standard/semantically meaningful in any other way?

For example, PHP automatically parses the content into $_POST, which seems to indicate that x-www-form-urlencoded is expected by the server. On the other hand, I could use Ajax to send a JSON object in the HTTP request content and set the Content-Type to application/json. At least some server technologies (e.g. WSGI) would not try to parse that, and instead provide it in original form to the script.

What MIME type should I use in POST and PUT requests in a RESTful API to ensure compliance with all server implementations of HTTP? I’m disregarding such technologies as SOAP and JSON-RPC because they tunnel protocols through HTTP instead of using HTTP as intended.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:56:05+00:00Added an answer on June 10, 2026 at 5:56 am

    Short Answer

    You should specify whichever content type best describes the HTTP message entity body.

    Long Answer

    For example, PHP automatically parses the content into $_POST, which seems to indicate that x-www-form-urlencoded is expected by the server.

    The server is not “expecting” x-www-form-urlencoded. PHP — in an effort to make the lives of developers simpler — will parse the form-encoded entity body into the $_POST superglobal if and only if Content-Type: x-www-form-urlencoded AND the entity body is actually a urlencoded key-value string. A similar process is followed for messages arriving with Content-Type: multipart/form-data to generate the $_FILES array. While helpful, these superglobals are unfortunately named and they obfuscate what’s really happening in terms of the actual HTTP transactions.

    What MIME type should I use in POST and PUT requests in a RESTful API
    to ensure compliance with all server implementations of HTTP?

    You should specify whichever content type best describes the HTTP message entity body. Always adhere to the official HTTP specification — you can’t go wrong if you do that. From RFC 2616 Sec 7.2.1 (emphasis added):

    Any HTTP/1.1 message containing an entity-body SHOULD include a
    Content-Type header field defining the media type of that body. If and
    only if the media type is not given by a Content-Type field, the
    recipient MAY attempt to guess the media type
    via inspection of its
    content and/or the name extension(s) of the URI used to identify the
    resource. If the media type remains unknown, the recipient SHOULD
    treat it as type “application/octet-stream”.

    Any mainstream server technology will adhere to these rules. Thoughtful web applications will not trust your Content-Type header, because it may or may not be correct. The originator of the message is free to send a totally bogus value. Usually the Content-Type header is checked as a preliminary validation measure, but the content is further verified by parsing the actual data. For example, if you’re PUTing JSON data to a REST service, the endpoint might first check to make sure that you’ve sent Content-Type: application/json, but then actually parse the entity body of your message to ensure it really is valid JSON.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the HTTP 1.1. spec: If the Request-URI does not point to an
In Pyramid , add_notfound_view(append_slash=True) will cause a request which does not match any view,
I use $_POST to read data sent through HTML forms to the server, narrowing
Can anyone tell me why this form does not properly submit values to server?
As stated in http://www.boutell.com/newfaq/misc/urllength.html , HTTP query string have limited length. It can be
This question seems to suggest that Ajax requests are not guaranteed to return in
This code checks for dead links. Since 3rd party Ajax requests are not allowed
I am trying to make ajax requests in my project, but I do not
I want to use WCF pipeline to handle requests of some custom format (not
In an ASP.Net WAP, the home page /default.aspx is receiving periodic requests from I-know-not-where.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.