Merge pull request #35 from petromykhailysyn/master
Added Cookie interceptor.
This commit is contained in:
commit
e31970f095
|
@ -0,0 +1,33 @@
|
|||
package ca.uhn.fhir.rest.client.interceptor;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
|
||||
import ca.uhn.fhir.rest.client.IClientInterceptor;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
|
||||
/**
|
||||
* HTTP interceptor to be used for adding Cookie to requests.
|
||||
* <p>
|
||||
* This interceptor adds a header resembling the following:<br/>
|
||||
* <code>Cookie: [key]=[value]</code><br/>
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class CookieInterceptor implements IClientInterceptor {
|
||||
private final String sessionCookie;
|
||||
|
||||
public CookieInterceptor(String sessionCookie) {
|
||||
this.sessionCookie = sessionCookie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptRequest(HttpRequestBase theRequest) {
|
||||
theRequest.addHeader(Constants.HEADER_COOKIE, sessionCookie); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptResponse(HttpResponse theResponse) {
|
||||
// nothing
|
||||
}
|
||||
}
|
|
@ -56,6 +56,7 @@ public class Constants {
|
|||
public static final String HEADER_CONTENT_LOCATION = "Content-Location";
|
||||
public static final String HEADER_CONTENT_LOCATION_LC = HEADER_CONTENT_LOCATION.toLowerCase();
|
||||
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
public static final String HEADER_COOKIE = "Cookie";
|
||||
public static final String HEADER_CORS_ALLOW_METHODS = "Access-Control-Allow-Methods";
|
||||
public static final String HEADER_CORS_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
|
||||
public static final String HEADER_CORS_EXPOSE_HEADERS = "Access-Control-Expose-Headers";
|
||||
|
|
Loading…
Reference in New Issue