Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
fix urlencoded content type
Browse files Browse the repository at this point in the history
  • Loading branch information
danielburger1337 committed Jul 12, 2022
1 parent 8009a22 commit 5e6f98f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

A minimal PHP component to nativly support user input parsing on http methods other than POST.

PHP natively only supports the parsing of multipart/form-data and application/x-www-urlencoded on POST http requests.
PHP natively only supports the parsing of multipart/form-data and application/x-www-form-urlencoded on POST http requests.

Many modern web applications also want use / support a) other http methods
like PUT or PATCH and b) other content encodings like JSON or XML.

This component provides a very simple and extensible object oriented api to support just that.

Internally this component uses the PHP native functions [json_decode](https://www.php.net/manual/en/function.json-decode) and [parse_str](https://www.php.net/manual/en/function.parse-str) (multpart/form-data gets "translated" to x-www-urlencoded) and therefore complex data structures (arrays and objects) are only limited by what those functions support. <br/>
Internally this component uses the PHP native functions [json_decode](https://www.php.net/manual/en/function.json-decode) and [parse_str](https://www.php.net/manual/en/function.parse-str) (multpart/form-data gets "translated" to x-www-form-urlencoded) and therefore complex data structures (arrays and objects) are only limited by what those functions support. <br/>
This effectifly means that HTMLForms like the following are `FULLY supported`.

```html
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sbsedv/input-converter",
"description": "A minimal PHP library to nativly support PUT, PATCH and DELETE user input in form of mutlipart/form-data, application/x-www-urlencoded and various JSON types like application/json with complex data structures (nested html forms).",
"description": "A minimal PHP library to nativly support PUT, PATCH and DELETE user input in form of mutlipart/form-data, application/x-www-form-urlencoded and various JSON types like application/json with complex data structures (nested html forms).",
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -13,7 +13,7 @@
"json",
"formdata",
"urlencoded",
"x-www-urlencoded",
"x-www-form-urlencoded",
"input converter",
"input",
"parser",
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/UrlEncodedConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class UrlEncodedConverter extends AbstractConverter
{
protected const ALLOWED_CONTENT_TYPE = 'application/x-www-urlencoded';
protected const ALLOWED_CONTENT_TYPE = 'application/x-www-form-urlencoded';

/**
* @param string[] $methods [optional] The supported http methods.
Expand Down
2 changes: 1 addition & 1 deletion tests/InputConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testUrlEncodedConverter(): void
$content = \http_build_query($content);

$request = Request::create('/', 'PUT', content: $content);
$request->headers->set('content-type', 'application/x-www-urlencoded');
$request->headers->set('content-type', 'application/x-www-form-urlencoded');

$inputConverter = $this->createInputConverter();

Expand Down

0 comments on commit 5e6f98f

Please sign in to comment.