Search in sources :

Example 1 with InternalJettyServletRequest

use of org.neo4j.server.rest.web.InternalJettyServletRequest 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());
}
Also used : RequestData(org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData) InternalJettyServletRequest(org.neo4j.server.rest.web.InternalJettyServletRequest) InternalJettyServletResponse(org.neo4j.server.rest.web.InternalJettyServletResponse) Test(org.junit.Test)

Example 2 with InternalJettyServletRequest

use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.

the class BatchOperations method performRequest.

protected void performRequest(UriInfo uriInfo, String method, String path, String body, Integer id, HttpHeaders httpHeaders, Map<Integer, String> locations, RequestData requestData) throws IOException, ServletException {
    path = replaceLocationPlaceholders(path, locations);
    body = replaceLocationPlaceholders(body, locations);
    URI targetUri = calculateTargetUri(uriInfo, path);
    InternalJettyServletResponse res = new InternalJettyServletResponse();
    InternalJettyServletRequest req = new InternalJettyServletRequest(method, targetUri.toString(), body, res, requestData);
    req.setScheme(targetUri.getScheme());
    addHeaders(req, httpHeaders);
    invoke(method, path, body, id, targetUri, req, res);
}
Also used : InternalJettyServletRequest(org.neo4j.server.rest.web.InternalJettyServletRequest) URI(java.net.URI) InternalJettyServletResponse(org.neo4j.server.rest.web.InternalJettyServletResponse)

Example 3 with InternalJettyServletRequest

use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.

the class BatchOperationsTest method testSchemeInInternalJettyServletRequestForHttps.

@Test
public void testSchemeInInternalJettyServletRequestForHttps() throws UnsupportedEncodingException {
    // when
    InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "https://localhost:7473/db/data/node", "{'name':'node1'}", new InternalJettyServletResponse(), mock(RequestData.class));
    // then
    assertEquals("https", req.getScheme());
}
Also used : RequestData(org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData) InternalJettyServletRequest(org.neo4j.server.rest.web.InternalJettyServletRequest) InternalJettyServletResponse(org.neo4j.server.rest.web.InternalJettyServletResponse) Test(org.junit.Test)

Example 4 with InternalJettyServletRequest

use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.

the class BatchOperationsTest method testSchemeInInternalJettyServletRequestForHttp.

@Test
public void testSchemeInInternalJettyServletRequestForHttp() throws UnsupportedEncodingException {
    // when
    InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "http://localhost:7473/db/data/node", "{'name':'node1'}", new InternalJettyServletResponse(), mock(RequestData.class));
    // then
    assertEquals("http", req.getScheme());
}
Also used : RequestData(org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData) InternalJettyServletRequest(org.neo4j.server.rest.web.InternalJettyServletRequest) InternalJettyServletResponse(org.neo4j.server.rest.web.InternalJettyServletResponse) Test(org.junit.Test)

Aggregations

InternalJettyServletRequest (org.neo4j.server.rest.web.InternalJettyServletRequest)4 InternalJettyServletResponse (org.neo4j.server.rest.web.InternalJettyServletResponse)4 Test (org.junit.Test)3 RequestData (org.neo4j.server.rest.web.InternalJettyServletRequest.RequestData)3 URI (java.net.URI)1