fix issue content-type default charset (#13009)

This commit is contained in:
Pierre-Quentin Warlot 2022-07-27 13:01:45 +02:00 committed by GitHub
parent e811d6bbe2
commit 6226dc2848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View File

@ -707,18 +707,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/** /**
* Parse content type object from header value * Parse content type object from header value
*/ */
private ContentType getContentType(String headerValue) throws ApiException { private ContentType getContentType(String headerValue) {
try { return ContentType.getByMimeType(headerValue);
return ContentType.parse(headerValue);
} catch (ParseException e) {
throw new ApiException("Could not parse content type " + headerValue);
}
} }
/** /**
* Get content type of a response or null if one was not provided * Get content type of a response or null if one was not provided
*/ */
private String getResponseMimeType(HttpResponse response) throws ApiException { private String getResponseMimeType(HttpResponse response) {
Header contentTypeHeader = response.getFirstHeader("Content-Type"); Header contentTypeHeader = response.getFirstHeader("Content-Type");
if (contentTypeHeader != null) { if (contentTypeHeader != null) {
return getContentType(contentTypeHeader.getValue()).getMimeType(); return getContentType(contentTypeHeader.getValue()).getMimeType();

View File

@ -662,18 +662,14 @@ public class ApiClient extends JavaTimeFormatter {
/** /**
* Parse content type object from header value * Parse content type object from header value
*/ */
private ContentType getContentType(String headerValue) throws ApiException { private ContentType getContentType(String headerValue) {
try { return ContentType.getByMimeType(headerValue);
return ContentType.parse(headerValue);
} catch (ParseException e) {
throw new ApiException("Could not parse content type " + headerValue);
}
} }
/** /**
* Get content type of a response or null if one was not provided * Get content type of a response or null if one was not provided
*/ */
private String getResponseMimeType(HttpResponse response) throws ApiException { private String getResponseMimeType(HttpResponse response) {
Header contentTypeHeader = response.getFirstHeader("Content-Type"); Header contentTypeHeader = response.getFirstHeader("Content-Type");
if (contentTypeHeader != null) { if (contentTypeHeader != null) {
return getContentType(contentTypeHeader.getValue()).getMimeType(); return getContentType(contentTypeHeader.getValue()).getMimeType();