forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJsonClientFilter.java
More file actions
25 lines (21 loc) · 877 Bytes
/
Copy pathJsonClientFilter.java
File metadata and controls
25 lines (21 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.github.dockerjava.jaxrs.filter;
import java.io.IOException;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.core.MediaType;
/**
*
* @author Konstantin Pelykh (kpelykh@gmail.com)
*
*/
public class JsonClientFilter implements ClientResponseFilter {
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
if (responseContext.getMediaType() != null
&& responseContext.getMediaType().isCompatible(MediaType.TEXT_PLAIN_TYPE)) {
String newContentType = "application/json" + responseContext.getMediaType().toString().substring(10);
responseContext.getHeaders().putSingle("Content-Type", newContentType);
}
}
}