Fix regression from new jetty version

This commit is contained in:
James Agnew 2018-09-11 08:27:34 -04:00
parent 261f2c73ab
commit ce6a9dbc36
3 changed files with 33 additions and 20 deletions

View File

@ -14,6 +14,7 @@ import java.util.*;
import java.util.Map.Entry;
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank;
/*
@ -182,7 +183,7 @@ public class UrlUtil {
}
private static void parseQueryString(String theQueryString, HashMap<String, List<String>> map) {
String query = theQueryString;
String query = defaultString(theQueryString);
if (query.startsWith("?")) {
query = query.substring(1);
}

View File

@ -823,9 +823,22 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
completeUrl = requestUrl.toString();
}
if (params == null) {
// If the request is coming in with a content-encoding, don't try to
// load the params from the content.
if (isNotBlank(theRequest.getHeader(Constants.HEADER_CONTENT_ENCODING))) {
if (isNotBlank(theRequest.getQueryString())) {
params = UrlUtil.parseQueryString(theRequest.getQueryString());
} else {
params = Collections.emptyMap();
}
}
if (params == null) {
params = new HashMap<>(theRequest.getParameterMap());
}
}
requestDetails.setParameters(params);

View File

@ -1,17 +1,6 @@
package ca.uhn.fhir.rest.client.interceptor;
import static org.junit.Assert.assertEquals;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.*;
package ca.uhn.fhir.rest.client;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.ResourceParam;
@ -19,14 +8,25 @@ import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.server.*;
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.util.PortUtil;
import ca.uhn.fhir.util.TestUtil;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.r4.model.Patient;
import org.junit.*;
import javax.servlet.http.HttpServletRequest;
import static org.junit.Assert.assertEquals;
public class CompressOutgoingContentInterceptorTest {
private static IGenericClient ourClient;
private static FhirContext ourCtx = FhirContext.forDstu2();
private static FhirContext ourCtx = FhirContext.forR4();
private static Patient ourLastPatient;
private static String ourLastReq;
private static String ourLastResponseEncoding;
@ -44,11 +44,11 @@ public class CompressOutgoingContentInterceptorTest {
ourClient.registerInterceptor(new GZipContentInterceptor());
Patient p = new Patient();
p.addName().addFamily("FAMILY");
p.addName().setFamily("FAMILY");
ourClient.create().resource(p).execute();
assertEquals("FAMILY", p.getName().get(0).getFamily().get(0).getValue());
Assert.assertEquals("FAMILY", p.getName().get(0).getFamily());
assertEquals("gzip", ourLastReq);
assertEquals("gzip", ourLastResponseEncoding);
}
@ -76,7 +76,6 @@ public class CompressOutgoingContentInterceptorTest {
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
}
public static class DummyPatientResourceProvider implements IResourceProvider {
@ -90,7 +89,7 @@ public class CompressOutgoingContentInterceptorTest {
}
@Override
public Class<? extends IResource> getResourceType() {
public Class<Patient> getResourceType() {
return Patient.class;
}