Update server mapping's host header

@param serverMappingId ID of server mapping
@param hostHeader value of host header
@return updated ServerRedirect
19562
public ServerRedirect updateServerRedirectHost(int serverMappingId, String hostHeader) {
        ServerRedirect redirect = new ServerRedirect();
        BasicNameValuePair[] params = {
            new BasicNameValuePair("hostHeader", hostHeader),
            new BasicNameValuePair("profileIdentifier", this._profileName)
        };
        try {
            JSONObject response = new JSONObject(doPost(BASE_SERVER + "/" + serverMappingId + "/host", params));
            redirect = getServerRedirectFromJSON(response);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return redirect;
    }
1173547
def update_domain_smarthost(self, domainid, serverid, data):
        """"""
        return self.api_call(
            ENDPOINTS['domainsmarthosts']['update'],
            dict(domainid=domainid, serverid=serverid),
            body=data)
1084015
private void replaceHeaders(URLRewritingConfig config, HeaderMap headers) {
        for (Entry<String, String> entry : headers) {
            String key = entry.getKey();
            String value = entry.getValue();
            value = doHeaderReplaceAll(value, config.getFromRegex(), config.getToReplacement());
            if (value != null) {
                headers.put(key, value);
            }
        }
    }
1222059
public boolean addMapping(String hostName, String contextPath, String globalName) {
        log.info("Add mapping global: {} host: {} context: {}", new Object[] { globalName, hostName, contextPath });
        final String key = getKey(hostName, contextPath);
        log.debug("Add mapping: {} => {}", key, globalName);
        return (mapping.putIfAbsent(key, globalName) == null);
    }
285878
public static String rehostLocation (
        HttpServletRequest req, String servername)
    {
        StringBuffer buf = req.getRequestURL();
        String csname = req.getServerName();
        int csidx = buf.indexOf(csname);
        if (csidx != -1) {
            buf.delete(csidx, csidx + csname.length());
            buf.insert(csidx, servername);
        }
        String query = req.getQueryString();
        if (!StringUtil.isBlank(query)) {
            buf.append("?").append(query);
        }
        return buf.toString();
    }
624871
public void addHostName(String hostName) {
		if(logger.isDebugEnabled()) {
			logger.debug(this);
			logger.debug("Adding hostname "+ hostName);
		}
		hostNames.add(hostName);
		if(dnsServerLocator != null) {
			dnsServerLocator.addLocalHostName(hostName);
		}
	}
682609
void updateHost() {
        try {
            _cachedLocalHostName.set(_wrappedHostResolver.getLocalHostName());
        } catch (final UnknownHostException e) {
            LOGGER.warn("Unable to resolve host", e);
        }
    }
784945
@Override
    public void addHeader(String key, String value)
    {
        _conn.setRequestProperty(key, value);
    }
531514
private String getHostHeaderForHost(String hostName) {
        List<ServerRedirect> servers = serverRedirectService.tableServers(requestInformation.get().client.getId());
        for (ServerRedirect server : servers) {
            if (server.getSrcUrl().compareTo(hostName) == 0) {
                String hostHeader = server.getHostHeader();
                if (hostHeader == null || hostHeader.length() == 0) {
                    return null;
                }
                return hostHeader;
            }
        }
        return null;
    }
821339
public static com.sun.net.httpserver.HttpServer bind(InetAddress address, int startPort, int maxPort) {
        com.sun.net.httpserver.HttpServer aServer = createServer();
        int port = -1;
        for (int possiblePort = startPort; port == -1 && possiblePort <= maxPort; possiblePort++) {
            try {
                InetSocketAddress s = new InetSocketAddress(address, possiblePort);
                aServer.bind(s, 1);
                port = possiblePort;
            } catch (IOException e) {
                // try next number
                continue;
            }
        }
        if (aServer.getAddress() == null) {
            throw new RuntimeException(new BindException("Unable to bind to: " + address.getHostAddress()));
        }
        return aServer;
    }
485929
public CustomHeadersInterceptor addHeaderMap(Map<String, String> headers) {
        for (Map.Entry<String, String> header : headers.entrySet()) {
            this.headers.put(header.getKey(), Collections.singletonList(header.getValue()));
        }
        return this;
    }
111781
public void setHttpProxy(String host, int port) {
        if (config == null) {
            config = new AipClientConfiguration();
        }
        this.config.setProxy(host, port, Proxy.Type.HTTP);
    }
1275883
@FFDCIgnore({ ChannelException.class, ChainException.class })
    public synchronized void update(String resolvedHostName) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "update chain " + this);
        }

        // Don't update or start the chain if it is disabled or the framework is stopping..
        if (!enabled || FrameworkState.isStopping())
            return;

        final ActiveConfiguration oldConfig = currentConfig;

        // The old configuration was "valid" if it existed, and if it was correctly configured
        final boolean validOldConfig = oldConfig == null ? false : oldConfig.validConfiguration;

        Map<String, Object> tcpOptions = owner.getTcpOptions();
        Map<String, Object> sslOptions = (isHttps) ? owner.getSslOptions() : null;
        Map<String, Object> httpOptions = owner.getHttpOptions();
        Map<String, Object> endpointOptions = owner.getEndpointOptions();
        Map<String, Object> remoteIpOptions = owner.getRemoteIpConfig();


        final ActiveConfiguration newConfig = new ActiveConfiguration(isHttps, tcpOptions, sslOptions, httpOptions, remoteIpOptions, endpointOptions, resolvedHostName);

        if (newConfig.configPort < 0 || !newConfig.complete()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "Stopping chain due to configuration " + newConfig);
            }

            // save the new/changed configuration before we start setting up the new chain
            currentConfig = newConfig;

            stop();
        } else {
            Map<Object, Object> chanProps;

            try {
                boolean sameConfig = newConfig.unchanged(oldConfig);
                if (validOldConfig) {
                    if (sameConfig) {
                        int state = chainState.get();
                        if (state == ChainState.STARTED.val) {
                            // If configurations are identical, see if the listening port is also the same
                            // which would indicate that the chain is running with the unchanged configuration
                            // toggle start/stop of chain if we are somehow active on a different port..
                            sameConfig = oldConfig.validateActivePort();
                            if (sameConfig) {
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(this, tc, "Configuration is unchanged, and chain is already started: " + oldConfig);
                                }
                                // EARLY EXIT: we have nothing else to do here: "new configuration" not saved
                                return;
                            } else {
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(this, tc, "Configuration is unchanged, but chain is running with a mismatched configuration: " + oldConfig);
                                }
                            }
                        } else if (state == ChainState.QUIESCED.val) {
                            // Chain is in the process of stopping.. we need to wait for it
                            // to finish stopping before we start it again
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(this, tc, "Configuration is unchanged, chain is quiescing, wait for stop: " + newConfig);
                            }
                            stopWait.waitForStop(cfw.getDefaultChainQuiesceTimeout(), this); // BLOCK
                        } else {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(this, tc, "Configuration is unchanged, chain must be started: " + newConfig);
                            }
                        }
                    }
                }

                if (!sameConfig) {
                    // Note that one path in the above block can change the value of sameConfig:
                    // if the started chain is actually running on a different port than we expect,
                    // something strange happened, and the whole thing should be stopped and restarted.
                    // We come through this block for the stop/teardown...

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "New/changed chain configuration " + newConfig);
                    }

                    // We've been through channel configuration before...
                    // We have to destroy/rebuild the chains because the channels don't
                    // really support dynamic updates. *sigh*
                    ChainData cd = cfw.getChain(chainName);
                    if (cd != null) {
                        cfw.stopChain(cd, cfw.getDefaultChainQuiesceTimeout());
                        stopWait.waitForStop(cfw.getDefaultChainQuiesceTimeout(), this); // BLOCK
                        cfw.destroyChain(cd);
                        cfw.removeChain(cd);
                    }
                    // Remove any channels that have to be rebuilt..
                    if (newConfig.tcpChanged(oldConfig))
                        removeChannel(tcpName);

                    if (newConfig.sslChanged(oldConfig))
                        removeChannel(sslName);

                    if (newConfig.httpChanged(oldConfig))
                        removeChannel(httpName);


                    if (newConfig.endpointChanged(oldConfig))
                        removeChannel(dispatcherName);
                }

                // save the new/changed configuration before we start setting up the new chain
                currentConfig = newConfig;

                // Define and register an EndPoint to represent this chain
                EndPointInfo ep = endpointMgr.defineEndPoint(endpointName, newConfig.configHost, newConfig.configPort);

                // TCP Channel
                ChannelData tcpChannel = cfw.getChannel(tcpName);
                if (tcpChannel == null) {
                    String typeName = (String) tcpOptions.get("type");
                    chanProps = new HashMap<Object, Object>(tcpOptions);
                    chanProps.put("endPointName", endpointName);
                    chanProps.put("hostname", ep.getHost());
                    chanProps.put("port", String.valueOf(ep.getPort()));

                    tcpChannel = cfw.addChannel(tcpName, cfw.lookupFactory(typeName), chanProps);
                }

                // SSL Channel
                if (isHttps) {
                    ChannelData sslChannel = cfw.getChannel(sslName);
                    if (sslChannel == null) {
                        chanProps = new HashMap<Object, Object>(sslOptions);
                        // Put the protocol version, which allows the http channel to dynamically
                        // know what http version it will use.
                        if (owner.getProtocolVersion() != null) {
                            chanProps.put(HttpConfigConstants.PROPNAME_PROTOCOL_VERSION, owner.getProtocolVersion());
                        }
                        sslChannel = cfw.addChannel(sslName, cfw.lookupFactory("SSLChannel"), chanProps);
                    }
                }

                // HTTP Channel
                ChannelData httpChannel = cfw.getChannel(httpName);
                if (httpChannel == null) {
                    chanProps = new HashMap<Object, Object>(httpOptions);
                    // Put the endpoint id, which allows us to find the registered access log
                    // dynamically
                    chanProps.put(HttpConfigConstants.PROPNAME_ACCESSLOG_ID, owner.getName());
                    // Put the protocol version, which allows the http channel to dynamically
                    // know what http version it will use.
                    if (owner.getProtocolVersion() != null) {
                        chanProps.put(HttpConfigConstants.PROPNAME_PROTOCOL_VERSION, owner.getProtocolVersion());
                    }
                    if(remoteIpOptions.get("id").equals("defaultRemoteIp")){
                        //Put the internal remoteIp set to false since the element was not configured to be used
                        chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_IP, "false");
                        chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_PROXIES, null);
                        chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_IP_ACCESS_LOG, null);
                    }
                    else{
                        chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_IP, "true");
                        //Check if the remoteIp is configured to use the remoteIp in the access log or if
                        //a custom proxy regex was provided
                        if(remoteIpOptions.containsKey("proxies")){
                            chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_PROXIES, remoteIpOptions.get("proxies"));
                        }
                        if(remoteIpOptions.containsKey("useRemoteIpInAccessLog")){
                            chanProps.put(HttpConfigConstants.PROPNAME_REMOTE_IP_ACCESS_LOG, remoteIpOptions.get("useRemoteIpInAccessLog"));
                        }
                    }




                    httpChannel = cfw.addChannel(httpName, cfw.lookupFactory("HTTPInboundChannel"), chanProps);
                }

                // HTTPDispatcher Channel
                ChannelData httpDispatcher = cfw.getChannel(dispatcherName);
                if (httpDispatcher == null) {
                    chanProps = new HashMap<Object, Object>();
                    chanProps.put(HttpDispatcherConfig.PROP_ENDPOINT, owner.getPid());

                    httpDispatcher = cfw.addChannel(dispatcherName, cfw.lookupFactory("HTTPDispatcherChannel"), chanProps);
                }

                // Add chain
                ChainData cd = cfw.getChain(chainName);
                if (null == cd) {
                    final String[] chanList;
                    if (isHttps)
                        chanList = new String[] { tcpName, sslName, httpName, dispatcherName };
                    else
                        chanList = new String[] { tcpName, httpName, dispatcherName };

                    cd = cfw.addChain(chainName, FlowType.INBOUND, chanList);
                    cd.setEnabled(enabled);
                    cfw.addChainEventListener(this, chainName);

                    // initialize the chain: this will find/create the channels in the chain,
                    // initialize each channel, and create the chain. If there are issues with any
                    // channel properties, they will surface here
                    // THIS INCLUDES ATTEMPTING TO BIND TO THE PORT
                    cfw.initChain(chainName);
                }

                // We configured the chain successfully
                newConfig.validConfiguration = true;
            } catch (ChannelException e) {
                handleStartupError(e, newConfig); // FFDCIgnore: CFW will have logged and FFDCd already
            } catch (ChainException e) {
                handleStartupError(e, newConfig); // FFDCIgnore: CFW will have logged and FFDCd already
            } catch (Exception e) {
                // The exception stack for this is all internals and does not belong in messages.log.
                Tr.error(tc, "config.httpChain.error", tcpName, e.toString());
                handleStartupError(e, newConfig);
            }

            if (newConfig.validConfiguration) {
                try {
                    // Start the chain: follow along to chainStarted method (CFW callback)
                    cfw.startChain(chainName);
                } catch (ChannelException e) {
                    handleStartupError(e, newConfig); // FFDCIgnore: CFW will have logged and FFDCd already
                } catch (ChainException e) {
                    handleStartupError(e, newConfig); // FFDCIgnore: CFW will have logged and FFDCd already
                } catch (Exception e) {
                    // The exception stack for this is all internals and does not belong in messages.log.
                    Tr.error(tc, "start.httpChain.error", tcpName, e.toString());
                    handleStartupError(e, newConfig);
                }
            }
        }
    }
1258048
public void updateServiceUri(String serviceName, String providerId,
            String uri) {
        getServiceDirectoryClient().updateServiceInstanceUri(serviceName, providerId, uri);
    }
857390
public void addAdditionalHeader(String key, String value)
    {
        if (this.additionalHeader == null)
        {
            this.additionalHeader = Maps.newLinkedHashMap();
        }

        this.additionalHeader.put(key, value);
    }
216286
public static Map createHeaderMap(PageContext pContext)
    {
        final HttpServletRequest request =
                (HttpServletRequest) pContext.getRequest();

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return request.getHeaderNames();
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return request.getHeader((String) pKey);
                } else {
                    return null;
                }
            }

            public boolean isMutable()
            {
                return false;
            }
        };
    }
281378
public final void setHost(final String host) throws UnknownHostException {
        this.host = host;
        final InetAddress[] inetAddresses = InetAddress.getAllByName(host);

        for (InetAddress address: inetAddresses) {
            final AddressHostMatcher matcher = new AddressHostMatcher();
            matcher.setIp(address.getHostAddress());
            this.matchersForHost.add(matcher);
        }
    }