-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from petromykhailysyn/master
Added Cookie interceptor.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/interceptor/CookieInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters