/** * <p>Adds the given values to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given values.</p> * * @param key The key with which the specified value is to be associated. * @param values The values to be added to the list associated with the specified key. */ public void add(String key, List<String> values) { h.add(key, values); }
/** * <p>Adds the given value to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given value.</p> * * @param key The key with which the specified value is to be associated. * @param value The value to be added to the list associated with the specified key. */ public void add(String key, String value) { h.add(key, value); }
public void addHeader(String name, String value) { headerFields.add(name, value); headerBlacklist.remove(name); }
/** * <p>Adds all the entries of the given map to this. This is the same as calling {@link #add(String, List)} for each * entry in <code>values</code>.</p> * * @param values The values to be added to this. */ public void addAll(Map<? extends String, ? extends List<String>> values) { for (Entry<? extends String, ? extends List<String>> entry : values.entrySet()) { add(entry.getKey(), entry.getValue()); } }
public static void copyHeaders(HttpServletRequest from, HttpRequest to) { for (Enumeration<String> it = from.getHeaderNames(); it.hasMoreElements(); ) { String key = it.nextElement(); for (Enumeration<String> value = from.getHeaders(key); value.hasMoreElements(); ) { to.headers().add(key, value.nextElement()); } } }
@Override public void addHeader(String name, String value) { parent.headers().add(name, value); }
@Override public void addHeader(String name, String value) { parent.headers().add(name, value); }
public FeedResponse( int status, BlockingQueue<OperationStatus> operations, int protocolVersion, String sessionId, int outstandingClientOperations, String hostName) { super(status); this.operations = operations; headers().add(Headers.SESSION_ID, sessionId); headers().add(Headers.VERSION, Integer.toString(protocolVersion)); headers().add(Headers.OUTSTANDING_REQUESTS, Integer.toString(outstandingClientOperations)); headers().add(Headers.HOSTNAME, hostName); }
@Override public void copyHeaders(HeaderFields target) { response.getHeaderNames().forEach( header -> target.add(header, new ArrayList<>(response.getHeaders(header))) ); }
/** * Copy custom HTTP headers from the search result over to the HTTP * response. * * @param outputHeaders * the headers which will be sent to a client * @param searchHeaders * the headers from the search result, or null */ private static void populateHeaders(HeaderFields outputHeaders, ListMap<String, String> searchHeaders) { if (searchHeaders == null) { return; } for (Map.Entry<String, List<String>> header : searchHeaders.entrySet()) { for (String value : header.getValue()) { outputHeaders.add(header.getKey(), value); } } }
@Override protected com.yahoo.jdisc.Response newResponse() { com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(statusToReturn); response.headers().add("Content-Type", Arrays.asList(new String[]{"application/json"})); return response; } }.connect(handler));
@Override protected com.yahoo.jdisc.Response newResponse() { com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(com.yahoo.jdisc.Response.Status.OK); response.headers().add("Content-Type", Arrays.asList(new String[]{"application/json"})); return response; } }.connect(handler));
public ServletRequest(HttpServletRequest request, URI uri) { super(request); this.request = request; this.uri = uri; super.getParameterMap().forEach( (key, values) -> parameters.put(key, Arrays.asList(values))); remoteHostAddress = request.getRemoteAddr(); remoteHostName = request.getRemoteHost(); remotePort = request.getRemotePort(); connectedAt = getConnection(request).getCreatedTimeStamp(); headerFields = new HeaderFields(); Enumeration<String> parentHeaders = request.getHeaderNames(); while (parentHeaders.hasMoreElements()) { String name = parentHeaders.nextElement(); Enumeration<String> values = request.getHeaders(name); while (values.hasMoreElements()) { headerFields.add(name, values.nextElement()); } } }
@Override protected Response newResponse() { Response response = new Response(Response.Status.OK); response.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json"); return response; }
if (c != null) { responseHeaders.add(BenchmarkingHeaders.NUM_HITS, String.valueOf(c.getRetrievedHitCount())); responseHeaders.add(BenchmarkingHeaders.NUM_FASTHITS, String.valueOf(c.getSummaryCount())); responseHeaders.add(BenchmarkingHeaders.TOTAL_HIT_COUNT, String.valueOf(c.getTotalHitCount())); responseHeaders.add(BenchmarkingHeaders.QUERY_HITS, String.valueOf(c.getRequestedHits())); responseHeaders.add(BenchmarkingHeaders.QUERY_OFFSET, String.valueOf(c.getRequestedOffset())); responseHeaders.add(BenchmarkingHeaders.NUM_ERRORS, String.valueOf(errorCount)); if (t != null) { if (t.getSummaryStartTime() != 0) { responseHeaders.add(BenchmarkingHeaders.SEARCH_TIME, String.valueOf(t.getSummaryStartTime() - t.getQueryStartTime())); responseHeaders.add(BenchmarkingHeaders.ATTR_TIME, "0"); responseHeaders.add(BenchmarkingHeaders.FILL_TIME, String.valueOf(renderStartTime - t.getSummaryStartTime())); } else { responseHeaders.add(BenchmarkingHeaders.SEARCH_TIME, String.valueOf(renderStartTime - t.getQueryStartTime())); responseHeaders.add(BenchmarkingHeaders.ATTR_TIME, "0"); responseHeaders.add(BenchmarkingHeaders.FILL_TIME, "0"); responseHeaders.add(BenchmarkingHeaders.DOCS_SEARCHED, String.valueOf(coverage.getDocs())); responseHeaders.add(BenchmarkingHeaders.NODES_SEARCHED, String.valueOf(coverage.getNodes())); responseHeaders.add(BenchmarkingHeaders.FULL_COVERAGE, String.valueOf(coverage.getFull() ? 1 : 0));
public void encodeSetCookieHeader(List<Cookie> cookies) { headers().remove(HttpHeaders.Names.SET_COOKIE); for (Cookie cookie : cookies) { headers().add(HttpHeaders.Names.SET_COOKIE, Cookie.toSetCookieHeaders(Arrays.asList(cookie))); } }
@Override protected Response newResponse() { Response response = new Response(Response.Status.OK); response.headers().add(HttpHeaders.Names.CONTENT_TYPE, resolveContentType(request.getUri())); return response; }
private static com.yahoo.jdisc.Request createDiscRequest(Request request, CurrentContainer currentContainer) { String scheme = getScheme(request.getUri()); com.yahoo.jdisc.Request discRequest; if ("http".equals(scheme) || "https".equals(scheme)) { com.yahoo.jdisc.http.HttpRequest httpRequest = com.yahoo.jdisc.http.HttpRequest.newServerRequest(currentContainer, URI.create(request.getUri()), com.yahoo.jdisc.http.HttpRequest.Method.valueOf(request.getMethod().name())); request.getUserPrincipal().ifPresent(httpRequest::setUserPrincipal); discRequest = httpRequest; } else { discRequest = new com.yahoo.jdisc.Request(currentContainer, URI.create(request.getUri())); } for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) { discRequest.headers().add(entry.getKey(), entry.getValue()); } discRequest.context().putAll(request.getAttributes()); return discRequest; }
result, query, renderer); if (hostResponseHeaderKey.isPresent()) response.headers().add(hostResponseHeaderKey.get(), selfHostname);