Skip to content

Commit

Permalink
modify getContentType method
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCqupt committed Aug 3, 2022
1 parent 56ccfff commit a2aa627
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,18 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* Parse content type object from header value
*/
private ContentType getContentType(String headerValue) {
return ContentType.getByMimeType(headerValue);
private ContentType getContentType(String headerValue) throws ApiException {
try {
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
*/
private String getResponseMimeType(HttpResponse response) {
private String getResponseMimeType(HttpResponse response) throws ApiException {
Header contentTypeHeader = response.getFirstHeader("Content-Type");
if (contentTypeHeader != null) {
return getContentType(contentTypeHeader.getValue()).getMimeType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,18 @@ protected Map<String, List<String>> transformResponseHeaders(Header[] headers) {
/**
* Parse content type object from header value
*/
private ContentType getContentType(String headerValue) {
return ContentType.getByMimeType(headerValue);
private ContentType getContentType(String headerValue) throws ApiException {
try {
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
*/
private String getResponseMimeType(HttpResponse response) {
private String getResponseMimeType(HttpResponse response) throws ApiException {
Header contentTypeHeader = response.getFirstHeader("Content-Type");
if (contentTypeHeader != null) {
return getContentType(contentTypeHeader.getValue()).getMimeType();
Expand Down

0 comments on commit a2aa627

Please sign in to comment.