public InetSocketAddress socketAddressFromHostHeader() { if (!Strings.isNullOrEmpty(getFirstHeader(HOST.toString()))) { boolean isSsl = isSecure() != null && isSecure(); String[] hostHeaderParts = getFirstHeader(HOST.toString()).split(":"); return new InetSocketAddress(hostHeaderParts[0], hostHeaderParts.length > 1 ? Integer.parseInt(hostHeaderParts[1]) : isSsl ? 443 : 80); } else { throw new IllegalArgumentException("Host header must be provided to determine remote socket address, the request does not include the \"Host\" header:" + NEW_LINE + this); } }
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024)) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeoutMillis) .attr(SECURE, httpRequest.isSecure() != null && httpRequest.isSecure()) .attr(REMOTE_SOCKET, remoteAddress) .attr(RESPONSE_FUTURE, httpResponseSettableFuture)
boolean cookiesMatch = matches(context, cookieMatcher, request.getCookies()); boolean keepAliveMatches = matches(context, keepAliveMatcher, request.isKeepAlive()); boolean sslMatches = matches(context, sslMatcher, request.isSecure());
protected HttpResponse makeRequest(HttpRequest httpRequest, Collection<String> headersToIgnore) { try { boolean isSsl = httpRequest.isSecure() != null && httpRequest.isSecure(); int port = (isSsl ? getServerSecurePort() : getServerPort()); httpRequest.withPath(addContextToPath(httpRequest.getPath().getValue()));
@Override public HttpRequest handle(HttpRequest httpRequest) { return request() .withHeader("Host", "localhost:" + httpRequest.getFirstHeader("x-echo-server-port")) .withHeader("x-test", httpRequest.getFirstHeader("x-test")) .withBody("some_overridden_body") .withSecure(httpRequest.isSecure()); } }
outputCookies(numberOfSpacesToIndent + 1, output, request.getCookieList()); outputQueryStringParameter(numberOfSpacesToIndent + 1, output, request.getQueryStringParameterList()); if (request.isSecure() != null) { appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output); output.append(".withSecure(").append(request.isSecure().toString()).append(")");
public HttpRequestDTO(HttpRequest httpRequest, Boolean not) { super(not); if (httpRequest != null) { method = httpRequest.getMethod(); path = httpRequest.getPath(); headers = httpRequest.getHeaders(); cookies = httpRequest.getCookies(); queryStringParameters = httpRequest.getQueryStringParameters(); body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
public HttpRequestTemplateObject(HttpRequest httpRequest) { if (httpRequest != null) { method = httpRequest.getMethod().getValue(); path = httpRequest.getPath().getValue(); for (Header header : httpRequest.getHeaderList()) { headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } for (Cookie cookie : httpRequest.getCookieList()) { cookies.put(cookie.getName().getValue(), cookie.getValue().getValue()); } for (Parameter parameter : httpRequest.getQueryStringParameterList()) { queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
public HttpRequest update(HttpRequest replaceRequest) { if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) { withMethod(replaceRequest.getMethod()); } if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) { withPath(replaceRequest.getPath()); } for (Header header : replaceRequest.getHeaderList()) { getHeaders().replaceEntry(header); } for (Cookie cookie : replaceRequest.getCookieList()) { withCookie(cookie); } for (Parameter parameter : replaceRequest.getQueryStringParameterList()) { getQueryStringParameters().replaceEntry(parameter); } if (replaceRequest.getBody() != null) { withBody(replaceRequest.getBody()); } if (replaceRequest.isSecure() != null) { withSecure(replaceRequest.isSecure()); } if (replaceRequest.isKeepAlive() != null) { withKeepAlive(replaceRequest.isKeepAlive()); } return this; } }
public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) { this.httpRequest = httpRequest; this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) { this.expectation = expectation; this.httpRequest = expectation.getHttpRequest(); this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
public InetSocketAddress socketAddressFromHostHeader() { if (!Strings.isNullOrEmpty(getFirstHeader(HOST.toString()))) { boolean isSsl = isSecure() != null && isSecure(); String[] hostHeaderParts = getFirstHeader(HOST.toString()).split(":"); return new InetSocketAddress(hostHeaderParts[0], hostHeaderParts.length > 1 ? Integer.parseInt(hostHeaderParts[1]) : isSsl ? 443 : 80); } else { throw new IllegalArgumentException("Host header must be provided to determine remote socket address, the request does not include the \"Host\" header:" + NEW_LINE + this); } }
public HttpRequestDTO(HttpRequest httpRequest, Boolean not) { super(not); if (httpRequest != null) { method = httpRequest.getMethod(); path = httpRequest.getPath(); headers = httpRequest.getHeaders(); cookies = httpRequest.getCookies(); queryStringParameters = httpRequest.getQueryStringParameters(); body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
public HttpRequestTemplateObject(HttpRequest httpRequest) { if (httpRequest != null) { method = httpRequest.getMethod().getValue(); path = httpRequest.getPath().getValue(); for (Header header : httpRequest.getHeaderList()) { headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } for (Cookie cookie : httpRequest.getCookieList()) { cookies.put(cookie.getName().getValue(), cookie.getValue().getValue()); } for (Parameter parameter : httpRequest.getQueryStringParameterList()) { queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
public HttpRequest update(HttpRequest replaceRequest) { if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) { withMethod(replaceRequest.getMethod()); } if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) { withPath(replaceRequest.getPath()); } for (Header header : replaceRequest.getHeaderList()) { getHeaders().replaceEntry(header); } for (Cookie cookie : replaceRequest.getCookieList()) { withCookie(cookie); } for (Parameter parameter : replaceRequest.getQueryStringParameterList()) { getQueryStringParameters().replaceEntry(parameter); } if (replaceRequest.getBody() != null) { withBody(replaceRequest.getBody()); } if (replaceRequest.isSecure() != null) { withSecure(replaceRequest.isSecure()); } if (replaceRequest.isKeepAlive() != null) { withKeepAlive(replaceRequest.isKeepAlive()); } return this; } }
public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) { this.httpRequest = httpRequest; this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) { this.expectation = expectation; this.httpRequest = expectation.getHttpRequest(); this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }