You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a test that needs to send a body with a .badRequest response, the content-type header is not set correctly. The headers() method on HttpResponse should evaluate the body of .badRequest the same way it does for .ok. It's a bit complicated by the fact that the associated data for .ok is not optional and .badRequest is optional, but if badRequest does have a body, it should be handled the same way.
The text was updated successfully, but these errors were encountered:
You can always use the HttpResponse.raw and provide your own Headers. See the following example:
letstatusCode=400letreasonPhrase="Bad Request"letheaders=["Content-Type":"application/json"]letresponse=HttpResponse.raw(statusCode, reasonPhrase , headers,{ writer in
// jsonData represent your JSON string to return converted to `Data`
// or any other implementing `HttpResponseBodyWriter`
try writer.write(jsonData)})
If I have a test that needs to send a body with a
.badRequest
response, the content-type header is not set correctly. Theheaders()
method onHttpResponse
should evaluate the body of.badRequest
the same way it does for.ok
. It's a bit complicated by the fact that the associated data for.ok
is not optional and.badRequest
is optional, but ifbadRequest
does have a body, it should be handled the same way.The text was updated successfully, but these errors were encountered: