Restore changes for 5502. (#5525)

* Restore changes for 5502.

* Spotless.
This commit is contained in:
Luke deGruchy 2023-12-01 10:16:56 -05:00 committed by GitHub
parent 59936ee70c
commit ec5402abd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -105,7 +105,8 @@ public enum Pointcut implements IPointcut {
void.class,
"ca.uhn.fhir.rest.client.api.IHttpRequest",
"ca.uhn.fhir.rest.client.api.IHttpResponse",
"ca.uhn.fhir.rest.client.api.IRestfulClient"),
"ca.uhn.fhir.rest.client.api.IRestfulClient",
"ca.uhn.fhir.rest.client.api.ClientResponseContext"),
/**
* <b>Server Hook:</b>

View File

@ -36,6 +36,7 @@ import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.RequestFormatParamStyleEnum;
import ca.uhn.fhir.rest.api.SummaryEnum;
import ca.uhn.fhir.rest.client.api.ClientResponseContext;
import ca.uhn.fhir.rest.client.api.IHttpClient;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.api.IHttpResponse;
@ -356,13 +357,20 @@ public abstract class BaseClient implements IRestfulClient {
? ((ResourceResponseHandler<? extends IBaseResource>) binding).getReturnType()
: null;
final ClientResponseContext clientResponseContext =
new ClientResponseContext(httpRequest, response, this, getFhirContext(), returnType);
HookParams responseParams = new HookParams();
responseParams.add(IHttpRequest.class, httpRequest);
responseParams.add(IHttpResponse.class, response);
responseParams.add(IRestfulClient.class, this);
responseParams.add(ClientResponseContext.class, clientResponseContext);
getInterceptorService().callHooks(Pointcut.CLIENT_RESPONSE, responseParams);
// Replace the contents of the response with whatever the hook returned, or the same response as before if
// it no-op'd
response = clientResponseContext.getHttpResponse();
String mimeType;
if (Constants.STATUS_HTTP_204_NO_CONTENT == response.getStatus()) {
mimeType = null;

View File

@ -0,0 +1,6 @@
---
type: add
issue: 5502
jira: SMILE-7262
title: "It is now possible to mutate an HTTP response from the CLIENT_RESPONSE Pointcut, and pass this mutated response
to downstream processing."