/** * Add a header to return as a Header object, if a header with * the same name already exists this will NOT be modified but * two headers will exist * * @param header a Header object */ public HttpResponse withHeader(Header header) { this.headers.withEntry(header); return this; }
/** * Adds one header to match on as a Header object where the header values list can be a list of strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param header the Header object which can have a values list of strings or regular expressions */ public HttpRequest withHeader(Header header) { this.headers.withEntry(header); return this; }
/** * Add a header to return as a Header object, if a header with * the same name already exists this will NOT be modified but * two headers will exist * * @param name the header name * @param values the header values */ public HttpResponse withHeader(String name, String... values) { this.headers.withEntry(name, values); return this; }
/** * Add a header to return as a Header object, if a header with * the same name already exists this will NOT be modified but * two headers will exist * * @param name the header name as a NottableString * @param values the header values which can be a varags of NottableStrings */ public HttpResponse withHeader(NottableString name, NottableString... values) { this.headers.withEntry(header(name, values)); return this; }
/** * Adds one header to match which can specified using plain strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param name the header name * @param values the header values which can be a varags of strings or regular expressions */ public HttpRequest withHeader(String name, String... values) { this.headers.withEntry(header(name, values)); return this; }
/** * Adds one header to match on or to not match on using the NottableString, each NottableString can either be a positive matching value, * such as string("match"), or a value to not match on, such as not("do not match"), the string values passed to the NottableString * can also be a plain string or a regex (for more details of the supported regex syntax * see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param name the header name as a NottableString * @param values the header values which can be a varags of NottableStrings */ public HttpRequest withHeader(NottableString name, NottableString... values) { this.headers.withEntry(header(name, values)); return this; }
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); }
private void setHeaders(HttpResponse httpResponse, FullHttpResponse fullHttpResponse) { Headers headers = new Headers(); for (String headerName : fullHttpResponse.headers().names()) { headers.withEntry(new Header(headerName, fullHttpResponse.headers().getAll(headerName))); } if (!headers.isEmpty()) { httpResponse.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); }
headers.withEntry(header);
/** * Add a header to return as a Header object, if a header with * the same name already exists this will NOT be modified but * two headers will exist * * @param header a Header object */ public HttpResponse withHeader(Header header) { this.headers.withEntry(header); return this; }
/** * Adds one header to match on as a Header object where the header values list can be a list of strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param header the Header object which can have a values list of strings or regular expressions */ public HttpRequest withHeader(Header header) { this.headers.withEntry(header); return this; }
/** * Add a header to return as a Header object, if a header with * the same name already exists this will NOT be modified but * two headers will exist * * @param name the header name * @param values the header values */ public HttpResponse withHeader(String name, String... values) { this.headers.withEntry(name, values); return this; }
/** * Adds one header to match which can specified using plain strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param name the header name * @param values the header values which can be a varags of strings or regular expressions */ public HttpRequest withHeader(String name, String... values) { this.headers.withEntry(header(name, values)); return this; }
/** * Adds one header to match on or to not match on using the NottableString, each NottableString can either be a positive matching value, * such as string("match"), or a value to not match on, such as not("do not match"), the string values passed to the NottableString * can also be a plain string or a regex (for more details of the supported regex syntax * see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param name the header name as a NottableString * @param values the header values which can be a varags of NottableStrings */ public HttpRequest withHeader(NottableString name, NottableString... values) { this.headers.withEntry(header(name, values)); return this; }
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); }
private void setHeaders(HttpResponse httpResponse, FullHttpResponse fullHttpResponse) { Headers headers = new Headers(); for (String headerName : fullHttpResponse.headers().names()) { headers.withEntry(new Header(headerName, fullHttpResponse.headers().getAll(headerName))); } if (!headers.isEmpty()) { httpResponse.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); }