private void setHeaders(HttpRequest httpRequest, HttpServletRequest httpServletRequest) { Headers headers = new Headers(); Enumeration<String> headerNames = httpServletRequest.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); List<String> mappedHeaderValues = new ArrayList<String>(); Enumeration<String> headerValues = httpServletRequest.getHeaders(headerName); while (headerValues.hasMoreElements()) { mappedHeaderValues.add(headerValues.nextElement()); } headers.withEntry(new Header(headerName, mappedHeaderValues.toArray(new String[mappedHeaderValues.size()]))); } httpRequest.withHeaders(headers); }
public HttpRequest onRequest(HttpRequest request) { if (request != null) { List<String> headersToRemove = Arrays.asList( "proxy-connection", "connection", "keep-alive", "transfer-encoding", "te", "trailer", "proxy-authorization", "proxy-authenticate", "upgrade" ); Headers headers = new Headers(); for (Header header : request.getHeaderList()) { if (!headersToRemove.contains(header.getName().getValue().toLowerCase(Locale.ENGLISH))) { headers.withEntry(header); } } HttpRequest clonedRequest = request.clone(); if (!headers.isEmpty()) { clonedRequest.withHeaders(headers); } return clonedRequest; } else { return null; } } }
private void setHeaders(HttpRequest httpRequest, FullHttpRequest fullHttpResponse) { Headers headers = new Headers(); HttpHeaders httpHeaders = fullHttpResponse.headers(); for (String headerName : httpHeaders.names()) { headers.withEntry(new Header(headerName, httpHeaders.getAll(headerName))); } httpRequest.withHeaders(headers); }
public HttpRequest buildObject() { return new HttpRequest() .withMethod(method) .withPath(path) .withQueryStringParameters(queryStringParameters) .withBody((body != null ? Not.not(body.buildObject(), body.getNot()) : null)) .withHeaders(headers) .withCookies(cookies) .withSecure(secure) .withKeepAlive(keepAlive); }
public HttpRequest clone() { return not(request(), not) .withMethod(method) .withPath(path) .withQueryStringParameters(getQueryStringParameters().clone()) .withBody(body) .withHeaders(getHeaders().clone()) .withCookies(getCookies().clone()) .withKeepAlive(keepAlive) .withSecure(secure); }
.withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header(not("requestHeaderNameOne"), string("requestHeaderValueOne")), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("OTHERrequestHeaderNameOne", "requestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo")
.withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header(not("requestHeaderNameOne"), not("requestHeaderValueOne")), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("requestHeaderNameOne", "requestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("requestHeaderNameOne", "requestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo")
.withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header(string("requestHeaderNameOne"), not("requestHeaderValueOne")), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("requestHeaderNameOne", "OTHERrequestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo")
.withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header(not("requestHeaderNameOne"), not("requestHeaderValueOne")), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("OTHERrequestHeaderNameOne", "requestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo") .withMethod("GET") .withPath(calculatePath("some_pathRequest")) .withHeaders( header("requestHeaderNameOne", "OTHERrequestHeaderValueOne"), header("requestHeaderNameTwo", "requestHeaderValueTwo")
.withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) .withHeaders(header("headerOtherName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore) .withHeaders(header("headerOtherName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore)
.withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore) .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore)
.withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore) .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")), headersToIgnore)
.withPath(calculatePath("echo")) .withMethod("POST") .withHeaders( header("x-test", "test_headers_and_body") .withPath(calculatePath("echo")) .withMethod("POST") .withHeaders( header("x-test", "test_headers_and_body")
param("queryStringParameterTwoName", "queryStringParameterTwoValue") .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore) param("queryStringParameterTwoName", "queryStringParameterTwoValue") .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
param("bodyParameterTwoName", "Parameter Two") )) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore) "&bodyParameterOneName=Parameter+One+Value+Two" + "&bodyParameterTwoName=Parameter+Two")) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
param("bodyParameterTwoName", "Parameter Two") )) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore) "&bodyParameterOneName=Parameter+One+Value+Two" + "&bodyParameterTwoName=Parameter+Two")) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
param("bodyParameterTwoName", "Parameter Two") )) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore) "&OTHERBodyParameterOneName=Parameter+One+Value+Two" + "&bodyParameterTwoName=Parameter+Two")) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
param("bodyParameterTwoName", "Parameter Two") )) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore) "&bodyParameterOneName=OTHER Parameter+One+Value+Two" + "&bodyParameterTwoName=Parameter+Two")) .withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
.withHeaders(header("headerNameRequest", "headerValueRequest")) .withCookies(cookie("cookieNameRequest", "cookieValueRequest")), headersToIgnore)
.withHeaders( header("headerNameRequest", "headerValueRequest")