use of org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData in project neo4j by neo4j.
the class BatchOperationsTest method shouldForwardMetadataFromRequestData.
@Test
public void shouldForwardMetadataFromRequestData() throws Exception {
// Given
RequestData mock = new RequestData("127.0.0.1", true, 1, "TheLocalName", "129.0.0.1", 2, "authorization/auth");
InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "https://localhost:7473/db/data/node", "", new InternalJettyServletResponse(), mock);
// When & then
assertEquals("127.0.0.1", req.getRemoteAddr());
assertException(() -> req.getRemoteHost(), UnsupportedOperationException.class, "Remote host-name lookup might prove expensive, this should be explicitly considered.");
assertTrue(req.isSecure());
assertEquals(1, req.getRemotePort());
assertEquals("TheLocalName", req.getLocalName());
assertEquals("129.0.0.1", req.getLocalAddr());
assertEquals(2, req.getLocalPort());
assertEquals("authorization/auth", req.getAuthType());
}
use of org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData in project neo4j by neo4j.
the class BatchOperations method parseAndPerform.
protected void parseAndPerform(UriInfo uriInfo, HttpHeaders httpHeaders, HttpServletRequest req, InputStream body, Map<Integer, String> locations) throws IOException, ServletException {
JsonParser jp = jsonFactory.createJsonParser(body);
JsonToken token;
RequestData requestData = RequestData.from(req);
while ((token = jp.nextToken()) != null) {
if (token == JsonToken.START_OBJECT) {
String jobMethod = "", jobPath = "", jobBody = "";
Integer jobId = null;
while ((token = jp.nextToken()) != JsonToken.END_OBJECT && token != null) {
String field = jp.getText();
jp.nextToken();
switch(field) {
case METHOD_KEY:
jobMethod = jp.getText().toUpperCase();
break;
case TO_KEY:
jobPath = jp.getText();
break;
case ID_KEY:
jobId = jp.getIntValue();
break;
case BODY_KEY:
jobBody = readBody(jp);
break;
default:
break;
}
}
// Read one job description. Execute it.
performRequest(uriInfo, jobMethod, jobPath, jobBody, jobId, httpHeaders, locations, requestData);
}
}
}
Aggregations