Understanding : content-type header

Post method

  • Request in the console
POST / HTTP/2.0
Host: foo.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 13

Content-Type: application/x-www-form-urlencoded

  • multipart/form-data

  • these two multipart and x-www-form-urlencoded are the mime type used by html form

  • these are request headers content-type :
  • it should have value among these two based on the browsers
  • it depends on type and amount of data
  • each character is equal to each byte

x-www-form-urlencoded :

in this query string is sent to the server in a request body as a single long string

MyVariableOne=ValueOne&MyVariableTwo=ValueTwo

  • here anything which is non alphanumeric that will be converted to hexadecimal %HH' menas a percnet sin and two characters it means for each non alphanumeric we have to use the three more bytes that will basicaly increase the content-length
  • examples of non alphanumeric : ``code (blank space) ~ (tilde) (grave accent) ! (exclamation mark) @ (at)

    (pound)

    $ (dollar sign) % (percent) ^ (carat)

- so if any of the content contains any of this character that will be replaced by `% + hexadecimal` that will basically increase the overall size of the payload 


#### **multipart/form-data**
1. each name value pairs is represented as a part in a MIME message.
2. each part is having its own mime headers, content-type and content-disposition, each part has its own name
3. we have to choose the boundary correctly that is not the case with the x-www-form-urlencoded.


#### maximum size supported in the request body : POST 
- this totally depends on the server side ,
- Most common supported size of the request body is 10MB and this size can be increased or decreased from the configuration.
- this size is limited to avoid DOS Attacks or these days DDOS.
- character escaping can increase the [[byte]] size of the request since all the non alphanumeric will be replaced by the %hexadecimal character which is mentioned in the previous discussion of the post request.
- how to limit the request size in php server  

```php
php_value post_max_size 2K