-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.x] Fixes
PUT
verb form url encoded bodies and file uploads (#126)
* Fixes `PUT` verb form url encoded bodies and file uploads * Adds missing test for lb
- Loading branch information
1 parent
e35ab60
commit 372fdf7
Showing
3 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,31 @@ public function test_request_body() | |
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_form_url_encoded_without_inline_input_method() | ||
{ | ||
$handler = new LoadBalancedOctaneHandler(); | ||
|
||
Route::put('/', function (Request $request) { | ||
return $request->all(); | ||
}); | ||
|
||
$response = $handler->handle([ | ||
'httpMethod' => 'PUT', | ||
'path' => '/', | ||
'headers' => [ | ||
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8', | ||
], | ||
'body' => <<<'EOF' | ||
name=nuno&[email protected] | ||
EOF | ||
]); | ||
|
||
static::assertEquals([ | ||
'name' => 'nuno', | ||
'email' => '[email protected]', | ||
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_file_uploads() | ||
{ | ||
$handler = new LoadBalancedOctaneHandler(); | ||
|
@@ -333,6 +358,50 @@ public function test_request_file_uploads() | |
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_file_uploads_without_inline_input_method() | ||
{ | ||
$handler = new LoadBalancedOctaneHandler(); | ||
|
||
Route::put('/', function (Request $request) { | ||
return array_merge($request->all(), [ | ||
'filename' => $request->file('file')->getClientOriginalName(), | ||
'file' => $request->file('file')->getContent(), | ||
]); | ||
}); | ||
|
||
$response = $handler->handle([ | ||
'httpMethod' => 'PUT', | ||
'path' => '/', | ||
'headers' => [ | ||
'Content-Type' => 'multipart/form-data; boundary=---------------------------317050813134112680482597024243', | ||
], | ||
'body' => <<<'EOF' | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="name" | ||
nuno | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="email" | ||
[email protected] | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="file"; filename="my_uploaded.txt" | ||
Content-Type: text/plain | ||
foo | ||
-----------------------------317050813134112680482597024243-- | ||
EOF | ||
]); | ||
|
||
static::assertEquals([ | ||
'name' => 'nuno', | ||
'email' => '[email protected]', | ||
'filename' => 'my_uploaded.txt', | ||
'file' => 'foo', | ||
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_cookies() | ||
{ | ||
$handler = new LoadBalancedOctaneHandler(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,31 @@ public function test_request_body() | |
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_form_url_encoded_without_inline_input_method() | ||
{ | ||
$handler = new OctaneHandler(); | ||
|
||
Route::put('/', function (Request $request) { | ||
return $request->all(); | ||
}); | ||
|
||
$response = $handler->handle([ | ||
'httpMethod' => 'PUT', | ||
'path' => '/', | ||
'headers' => [ | ||
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8', | ||
], | ||
'body' => <<<'EOF' | ||
name=nuno&[email protected] | ||
EOF | ||
]); | ||
|
||
static::assertEquals([ | ||
'name' => 'nuno', | ||
'email' => '[email protected]', | ||
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_cookies() | ||
{ | ||
$handler = new OctaneHandler(); | ||
|
@@ -357,6 +382,50 @@ public function test_request_file_uploads() | |
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_file_uploads_without_inline_input_method() | ||
{ | ||
$handler = new OctaneHandler(); | ||
|
||
Route::put('/', function (Request $request) { | ||
return array_merge($request->all(), [ | ||
'filename' => $request->file('file')->getClientOriginalName(), | ||
'file' => $request->file('file')->getContent(), | ||
]); | ||
}); | ||
|
||
$response = $handler->handle([ | ||
'httpMethod' => 'PUT', | ||
'path' => '/', | ||
'headers' => [ | ||
'Content-Type' => 'multipart/form-data; boundary=---------------------------317050813134112680482597024243', | ||
], | ||
'body' => <<<'EOF' | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="name" | ||
nuno | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="email" | ||
[email protected] | ||
-----------------------------317050813134112680482597024243 | ||
Content-Disposition: form-data; name="file"; filename="my_uploaded.txt" | ||
Content-Type: text/plain | ||
foo | ||
-----------------------------317050813134112680482597024243-- | ||
EOF | ||
]); | ||
|
||
static::assertEquals([ | ||
'name' => 'nuno', | ||
'email' => '[email protected]', | ||
'filename' => 'my_uploaded.txt', | ||
'file' => 'foo', | ||
], json_decode($response->toApiGatewayFormat()['body'], true)); | ||
} | ||
|
||
public function test_request_query_string() | ||
{ | ||
$handler = new OctaneHandler(); | ||
|