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
When an HTTP request comes back with a Content-Type header value of "application/json;charset=utf-8", logging the response Body#representationOfBytes fails to match with this content type because of the missing space. https://www.rfc-editor.org/rfc/rfc2045#section-5.1 : The original spec outlining Content-Type header formatting doesn't explicitly declare whitespaces to be present before a parameter. https://tools.ietf.org/html/rfc7231#section-3.1.1.1 : Updates to the spec do explicitly declare an optional whitespace be present before a parameter.
To Reproduce
Steps to reproduce the behavior:
Write a client with: FuelManager.instance.addResponseInterceptor { LogResponseInterceptor.invoke(it) }
Make a request to a server that responds with application/json;charset=utf-8 as the content type and a proper JSON body.
Observe when logging the Body:... the actual body is not represented, instead it say (for example): Body: (1024 bytes of application/json;charset=utf-8)
I've copied the regex to a regex tester tool like https://regex101.com/ and tried to match with "application/json;charset=utf-8" but failed. Of course, testing with "application/json; charset=utf-8" passed. A quick modification to the regex allows for both: ^(?:text/.*|application/(?:csv|javascript|json|typescript|xml|x-yaml|x-www-form-urlencoded|vnd\.coffeescript)|.*\+(?:xml|json))(;(?: |)charset=.+)*$
Additionally, application/json media types are generally assumed to be encoded in utf-8 and often times, servers respond with Content-Type simply application/json.
Expected behavior
Logging the response Body should properly log the body opposed to "($lengthLabel of $actualContentType)"
Bug Report
Description
When an HTTP request comes back with a Content-Type header value of "application/json;charset=utf-8", logging the response
Body#representationOfBytes
fails to match with this content type because of the missing space.https://www.rfc-editor.org/rfc/rfc2045#section-5.1 : The original spec outlining Content-Type header formatting doesn't explicitly declare whitespaces to be present before a parameter.
https://tools.ietf.org/html/rfc7231#section-3.1.1.1 : Updates to the spec do explicitly declare an optional whitespace be present before a parameter.
To Reproduce
Steps to reproduce the behavior:
FuelManager.instance.addResponseInterceptor { LogResponseInterceptor.invoke(it) }
application/json;charset=utf-8
as the content type and a proper JSON body.Body: (1024 bytes of application/json;charset=utf-8)
I've copied the regex to a regex tester tool like https://regex101.com/ and tried to match with "application/json;charset=utf-8" but failed. Of course, testing with "application/json; charset=utf-8" passed. A quick modification to the regex allows for both:
^(?:text/.*|application/(?:csv|javascript|json|typescript|xml|x-yaml|x-www-form-urlencoded|vnd\.coffeescript)|.*\+(?:xml|json))(;(?: |)charset=.+)*$
Additionally,
application/json
media types are generally assumed to be encoded in utf-8 and often times, servers respond with Content-Type simplyapplication/json
.Expected behavior
Logging the response Body should properly log the body opposed to
"($lengthLabel of $actualContentType)"
Environment
Development Machine
Additional Context
I'm writing an Android client which makes REST requests to a Spring Boot server. The MediaType enum: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/MediaType.html#APPLICATION_JSON_UTF8 does not include a space.
The text was updated successfully, but these errors were encountered: