Don't try to detect response format if method return nothing (#2073)

This commit is contained in:
Gocha Ossinkine
2019-02-14 15:55:40 +05:00
committed by Akihito Nakano
parent 2593d78ce6
commit 161cb88e88
4 changed files with 16 additions and 122 deletions

View File

@@ -67,15 +67,6 @@ class UserController extends Controller
return new Response('', 415);
}
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -121,12 +112,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
@@ -154,15 +144,6 @@ class UserController extends Controller
return new Response('', 415);
}
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -210,12 +191,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
@@ -243,15 +223,6 @@ class UserController extends Controller
return new Response('', 415);
}
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -299,12 +270,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
@@ -324,15 +294,6 @@ class UserController extends Controller
*/
public function deleteUserAction(Request $request, $username)
{
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -379,12 +340,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
@@ -577,15 +537,6 @@ class UserController extends Controller
*/
public function logoutUserAction(Request $request)
{
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -615,12 +566,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
@@ -648,15 +598,6 @@ class UserController extends Controller
return new Response('', 415);
}
// Figure out what data format to return to the client
$produces = [];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
@@ -713,12 +654,11 @@ class UserController extends Controller
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)