Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public void setHeader(String name, String value) {
public void addHeader(String name, String value) {
clientRequest.headers().add(name, value);
}

@Override
public String getContextPath() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ public String getServletPath() {
return this.getPathInfo();
}

@Override
public String getContextPath() {
return "";
}

@Override
public ServletInputStream getInputStream() throws IOException {
if (inputStream == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,9 @@ public void testAddHeader() {
request.addHeader("name", "v2");
Assert.assertThat(headers.getAll("name"), Matchers.contains("v1", "v2"));
}

@Test
public void testGetContextPath() {
Assert.assertEquals("", request.getContextPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ public void testGetServletPath() {
Assert.assertEquals("/path", request.getServletPath());
}

@Test
public void testGetContextPath() {
Assert.assertEquals("", request.getContextPath());
}

@Test
public void testGetInputStream() throws IOException {
Buffer body = Buffer.buffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class InvocationToHttpServletRequest extends AbstractHttpServletRequest {
public InvocationToHttpServletRequest(Invocation invocation) {
this.swaggerOperation = invocation.getOperationMeta().getExtData(RestConst.SWAGGER_REST_OPERATION);
this.args = invocation.getArgs();
this.sockerAddress = (SocketAddress)invocation.getHandlerContext().get(Const.REMOTE_ADDRESS);
this.sockerAddress = (SocketAddress) invocation.getHandlerContext().get(Const.REMOTE_ADDRESS);
}

@Override
Expand Down Expand Up @@ -109,14 +109,19 @@ public String getPathInfo() {
public String getRemoteAddr() {
return this.sockerAddress == null ? "" : this.sockerAddress.host();
}

@Override
public String getRemoteHost() {
return this.sockerAddress == null ? "" : this.sockerAddress.host();
}

@Override
public int getRemotePort() {
return this.sockerAddress == null ? 0 : this.sockerAddress.port();
}

@Override
public String getContextPath() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class TestInvocationToHttpServletRequest {

@Mocked
Object[] args;

@Mocked
SocketAddress socketAddress;

Map<String, Object> handlerContext = new HashMap<>();

HttpServletRequest request;
Expand Down Expand Up @@ -316,4 +316,10 @@ public void testGetRemoteAddressEmpty(@Mocked Invocation invocation) throws Exce
Assert.assertEquals(host, "");
Assert.assertEquals(port, 0);
}

@Test
public void testGetContextPath(@Mocked Invocation invocation) throws Exception {
InvocationToHttpServletRequest request = new InvocationToHttpServletRequest(invocation);
Assert.assertEquals("", request.getContextPath());
}
}