Remove any protocol-level headers from the clients request that
do not apply to the new request we are sending to the remote server.

@param request
@param destination
775474
protected void prepareForwardedRequestHeaders(RequestData request, ForwardDestination destination) {
        HttpHeaders headers = request.getHeaders();
        headers.set(HOST, destination.getUri().getAuthority());
        headers.remove(TE);
    }
1194074
public static void removeRequest (@Nonnull @Nonempty final String sRequestID)
  {
    final RequestTracker aTracker = getGlobalSingletonIfInstantiated (RequestTracker.class);
    if (aTracker != null)
      aTracker.m_aRequestTrackingMgr.removeRequest (sRequestID, s_aParallelRunningCallbacks);
  }
1231137
@Override
	public void filter(final ClientRequestContext requestContext, final ClientResponseContext responseContext) {
		final List<String> serializedHeaders = responseContext.getHeaders().get(TraceeConstants.TPIC_HEADER);
		if (serializedHeaders != null && backend.getConfiguration().shouldProcessContext(IncomingResponse)) {
			final Map<String, String> parsed = transportSerialization.parse(serializedHeaders);
			backend.putAll(backend.getConfiguration().filterDeniedParams(parsed, IncomingResponse));
		}
	}
1236639
public void deletePipeline(DeletePipelineRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getPipelineName(), 
                "The parameter pipelineName should NOT be null or empty string.");
        InternalRequest internalRequest =
                createRequest(HttpMethodName.DELETE, request, PIPELINE, request.getPipelineName());

        invokeHttpClient(internalRequest, CreatePipelineResponse.class);
    }
579815
private void copyHeadersFromClient(HttpServletRequest pRequest, HttpURLConnection pRemoteConnection) {
        Enumeration headerNames = pRequest.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String headerName = (String) headerNames.nextElement();
            Enumeration headerValues = pRequest.getHeaders(headerName);

            // Skip the "host" header, as we want something else
            if (HTTP_REQUEST_HEADER_HOST.equalsIgnoreCase(headerName)) {
                // Skip this header
                headerName = null;
            }

            // Set the the header to the remoteConnection
            if (headerName != null) {
                // Convert from multiple line to single line, comma separated, as
                // there seems to be a shortcoming in the URLConneciton API...
                StringBuilder headerValue = new StringBuilder();
                while (headerValues.hasMoreElements()) {
                    String value = (String) headerValues.nextElement();
                    headerValue.append(value);
                    if (headerValues.hasMoreElements()) {
                        headerValue.append(", ");
                    }
                }

                //System.out.println("client -->>> remote: " + headerName + ": " + headerValue);
                pRemoteConnection.setRequestProperty(headerName, headerValue.toString());
            }
        }
    }
1029898
public void copyHeaders(DriverRequest originalRequest, HttpRequest httpRequest) {
        String baseUrl = originalRequest.getBaseUrl().toString();
        String visibleBaseUrl = originalRequest.getVisibleBaseUrl();
        for (Header header : originalRequest.getOriginalRequest().getAllHeaders()) {
            String name = header.getName();
            // Special headers
            if (HttpHeaders.REFERER.equalsIgnoreCase(name) && isForwardedRequestHeader(HttpHeaders.REFERER)) {
                String value = header.getValue();
                value = urlRewriter.rewriteReferer(value, baseUrl, visibleBaseUrl);
                httpRequest.addHeader(name, value);
                // All other headers are copied if allowed
            } else if (isForwardedRequestHeader(name)) {
                httpRequest.addHeader(header);
            }
        }
        // process X-Forwarded-For header
        String remoteAddr = originalRequest.getOriginalRequest().getRemoteAddr();

        if (remoteAddr != null) {
            String forwardedFor = null;
            if (httpRequest.containsHeader("X-Forwarded-For")) {
                forwardedFor = httpRequest.getFirstHeader("X-Forwarded-For").getValue();
            }

            if (forwardedFor == null) {
                forwardedFor = remoteAddr;
            } else {
                forwardedFor = forwardedFor + ", " + remoteAddr;
            }

            httpRequest.setHeader("X-Forwarded-For", forwardedFor);
        }

        // Process X-Forwarded-Proto header
        if (!httpRequest.containsHeader("X-Forwarded-Proto")) {
            httpRequest.addHeader("X-Forwarded-Proto",
                    UriUtils.extractScheme(originalRequest.getOriginalRequest().getRequestLine().getUri()));
        }
    }
546566
@Deprecated
    public static void removeHeader(HttpMessage message, String name) {
        message.headers().remove(name);
    }
263014
@InterfaceAudience.Public
    public void setHeaders(Map<String, Object> requestHeadersParam) {
        if (requestHeadersParam != null && !requestHeaders.equals(requestHeadersParam)) {
            requestHeaders = requestHeadersParam;
        }
    }
684462
@Override
  public void clearHeaders(BindingProvider soapClient) {
    getContextHandlerFromClient(soapClient).clearHeaders();
    soapClient.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
        new HashMap<String, List<String>>());
  }
1374437
@Override
  public void clearHeaders(Stub soapClient) {
    soapClient._setProperty(HTTPConstants.REQUEST_HEADERS, new Hashtable<String, String>());
    soapClient.clearHeaders();
  }
85725
public void deleteSubnet(DeleteSubnetRequest deleteSubnetRequest) {
        checkNotNull(deleteSubnetRequest, "request should not be null.");
        checkNotNull(deleteSubnetRequest.getSubnetId(), "request subnetId should not be null.");
        if (Strings.isNullOrEmpty(deleteSubnetRequest.getClientToken())) {
            deleteSubnetRequest.setClientToken(this.generateClientToken());
        }
        InternalRequest internalRequest = this.createRequest(
                deleteSubnetRequest, HttpMethodName.DELETE, SUBNET_PREFIX, deleteSubnetRequest.getSubnetId());
        internalRequest.addParameter("clientToken", deleteSubnetRequest.getClientToken());
        this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
642789
public static void adjustNoChunkedEncoding(ClientRequest request, String requestBody) {
        String fixedLengthString = request.getRequestHeaders().getFirst(Headers.CONTENT_LENGTH);
        String transferEncodingString = request.getRequestHeaders().getLast(Headers.TRANSFER_ENCODING);
        if(transferEncodingString != null) {
            request.getRequestHeaders().remove(Headers.TRANSFER_ENCODING);
        }
        //if already specify a content-length, should use what they provided
        if(fixedLengthString != null && Long.parseLong(fixedLengthString) > 0) {
            return;
        }
        if(!StringUtils.isEmpty(requestBody)) {
            long contentLength = requestBody.getBytes(UTF_8).length;
            request.getRequestHeaders().put(Headers.CONTENT_LENGTH, contentLength);
        }

    }
552650
protected void removeExpiredPortletCookies(HttpServletRequest request) {
        Map<String, SessionOnlyPortletCookieImpl> sessionOnlyCookies =
                getSessionOnlyPortletCookieMap(request);
        for (Entry<String, SessionOnlyPortletCookieImpl> entry : sessionOnlyCookies.entrySet()) {
            String key = entry.getKey();
            SessionOnlyPortletCookieImpl sessionOnlyCookie = entry.getValue();
            if (sessionOnlyCookie.getExpires().isBeforeNow()) {
                sessionOnlyCookies.remove(key);
            }
        }
    }
733056
void removeClientChannel(HttpRoute httpRoute, Http2ClientChannel http2ClientChannel) {
        EventLoopPool.PerRouteConnectionPool perRouteConnectionPool = fetchPerRoutePool(httpRoute,
                                                                                        http2ClientChannel.getChannel()
                                                                                            .eventLoop());
        if (perRouteConnectionPool != null) {
            perRouteConnectionPool.removeChannel(http2ClientChannel);
        }
    }
1004242
public void cleanUp(RESTRequest request) {
        //We need to loop through the clients but we don't want to synchronize
        //the entire map, which would block new clients from entering and block existing 
        //clients from continuing their work.  So we iterate and possibly remove by just
        //using the built-in concurrency of ConcurrentHashMap.
        final Iterator<Entry<Integer, ClientNotificationArea>> clients = inboxes.entrySet().iterator();

        while (clients.hasNext()) {
            Entry<Integer, ClientNotificationArea> client = clients.next();

            //Check for time outs
            ClientNotificationArea inbox = client.getValue();
            if (inbox.timedOut()) {
                //cleanup
                inbox.cleanUp(request);

                //Emit the warning
                Tr.warning(tc, "jmx.connector.server.rest.notification.timeout.warning", client.getKey());

                //remove the client inbox from the map (using the Iterator.remove() method)
                clients.remove();
            }
        }

    }
968592
private static void stripTransportDetails(Metadata metadata) {
    metadata.discardAll(HTTP2_STATUS);
    metadata.discardAll(InternalStatus.CODE_KEY);
    metadata.discardAll(InternalStatus.MESSAGE_KEY);
  }
1350733
@Override
    public void setRequestHeader(Header header) {
        
        Header[] headers = getRequestHeaderGroup().getHeaders(header.getName());
        
        for (int i = 0; i < headers.length; i++) {
            getRequestHeaderGroup().removeHeader(headers[i]);
        }
        
        getRequestHeaderGroup().addHeader(header);
        
    }