Sets the specified {@link HttpResponse} which responds to this request. This is always called
by the {@link HttpServerHandler} after the handler gets the {@link HttpResponse} from a {@link Service}.
196324
void setResponse(HttpResponse response) {
        if (isResponseAborted) {
            // This means that we already tried to close the request, so abort the response immediately.
            if (!response.isComplete()) {
                response.abort();
            }
        } else {
            this.response = response;
        }
    }
876679
def set(self, response: 'requests.Response') -> None:
        
        self.data[response.url] = SavedEndpoint(
            response.json(),
            self._get_expiration(response.headers)
        )
1155456
public void setRequestHeader(String header, String value) {
        LOG.entering(CLASS_NAME, "setRequestHeader", new Object[] {header, value});
        HttpRequestUtil.validateHeader(header);
        connection.addRequestProperty(header, value);
    }
946540
private <T> HttpResponseHandler<T> getNonNullResponseHandler(
            HttpResponseHandler<T> responseHandler) {
        if (responseHandler != null) {
            return responseHandler;
        } else {
            // Return a Dummy, No-Op handler
            return new HttpResponseHandler<T>() {

                @Override
                public T handle(HttpResponse response) throws Exception {
                    return null;
                }

                @Override
                public boolean needsConnectionLeftOpen() {
                    return false;
                }
            };
        }
    }
1320273
@Override
	public void onResponse( Object cookie, ResponseJSO response, int msgLevel, String msg )
	{
		PendingRequestInfo info = (PendingRequestInfo) cookie;

		// Store answer in cache
		if( info.fStoreResultInCache )
			cache.put( info.requestKey, response );

		// give the result to all the subscribees
		for( RequestCallInfo call : info.subscriptions )
			call.setResult( msgLevel, msg, null, response );

		// forget this request
		pendingRequests.remove( info );

		// calls back the clients
		checkAnswersToGive();
	}
917843
@Override
    public void handle(T result, HttpResponse response) {
        result.setRequesterCharged(response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null);
    }
1363475
@Override
    public void setResponseHeader(String key, String value) {
        this.response.setResponseHeader(key, value);
    }
148614
@Override
    public HttpServerRequest handler(Handler<Buffer> handler) {
        handler.handle(context.getBody());
        return this;
    }
1108591
private void serve(HttpRequest request, HttpResponse response) {
		String url = request.getUri();
		System.out.println("[Server] serve " + url);
		IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK.traceIncomingWebRequest(webAppInfo, url, request.getMethod());

		// add request header, parameter and remote address before start:
		for (Entry<String, List<String>> headerField : request.getHeaders().entrySet()) {
			for (String value : headerField.getValue()) {
				incomingWebrequestTracer.addRequestHeader(headerField.getKey(), value);
			}
		}
		for (Entry<String, List<String>> parameter : request.getParameters().entrySet()) {
			for (String value : parameter.getValue()) {
				incomingWebrequestTracer.addParameter(parameter.getKey(), value);
			}
		}
		incomingWebrequestTracer.setRemoteAddress(request.getRemoteIpAddress());

		incomingWebrequestTracer.start();
		try {
			response.setContent("Hello world!".getBytes());
			response.setStatusCode(200);
			incomingWebrequestTracer.setStatusCode(200);
		} catch (Exception e) {
			// we assume, container is sending http 500 in case of exception is thrown while serving an request:
			incomingWebrequestTracer.error(e);
			e.printStackTrace();
			throw new RuntimeException(e);
		} finally {
			incomingWebrequestTracer.end();
		}
	}
177257
public final void setCustomResponseHeaders (@Nullable final HttpHeaderMap aOther)
  {
    m_aResponseHeaderMap.removeAll ();
    if (aOther != null)
      m_aResponseHeaderMap.setAllHeaders (aOther);
  }
426959
protected void handleResponse(Object control) {
		byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control);
        if(result == null) {
            more = false;
        }
		this.cookie = new PagedResultsCookie(result);
        this.resultSize = (Integer) invokeMethod("getResultSize", responseControlClass, control);
	}
578588
@Override
    public void setResponse(HttpResponseMessage msg) throws IllegalResponseObjectException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "setResponse: " + msg);
        }

        // null message isn't allowed
        if (null == msg) {
            throw new IllegalResponseObjectException("Illegal null message");
        }

        // save new object as our response object
        HttpResponseMessageImpl temp = null;
        try {
            temp = (HttpResponseMessageImpl) msg;
        } catch (ClassCastException cce) {
            // no FFDC required
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Non msg impl passed to setResponse");
            }
            throw new IllegalResponseObjectException("Invalid message provided");
        }

        // possibly clean up any existing response object
        if (null != getMyResponse() && isResponseOwner()) {
            if (!getMyResponse().equals(temp)) {
                getMyResponse().destroy();
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(tc, "Caller overlaying same message");
                }
            }
        }
        setMyResponse(temp);
        getMyResponse().init(this);
        // moving the response to the inbound side will use the inbound sides
        // configured header change limit
        getMyResponse().setHeaderChangeLimit(getHttpConfig().getHeaderChangeLimit());
        updatePersistence(getMyResponse());

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setResponse");
        }
    }
1080921
private void setHeader(HttpServletResponse response, String name, String value) {
        if(response.containsHeader(value)) {
              response.setHeader(name, value);
        } else {
            response.addHeader(name, value);
        }
    }
1185707
private void setResponseElements(IntuitMessage intuitMessage, HttpURLConnection httpUrlConnection) throws FMSException {
		LOG.debug("Response headers:"+httpUrlConnection.getHeaderFields());
		ResponseElements responseElements = intuitMessage.getResponseElements();
		responseElements.setEncodingHeader(httpUrlConnection.getContentEncoding());
		responseElements.setContentTypeHeader(httpUrlConnection.getContentType());		
		try {
			responseElements.setStatusCode(httpUrlConnection.getResponseCode());
			
			InputStream responseStream;
			try {
				responseStream = httpUrlConnection.getInputStream();
			}
			catch (IOException ioe) {
				// Any error response from the server. Read the error stream instead of the responseStream. It contains the response from the server for the error code.
				responseStream = httpUrlConnection.getErrorStream();
			}
		
			responseElements.setResponseContent(getCopyOfResponseContent(responseStream));
		} catch (IllegalStateException e) {
			LOG.error("IllegalStateException while get the content from HttpRespose.", e);
			throw new FMSException(e);
		} catch (Exception e) {
			LOG.error("IOException in HTTPURLConnectionInterceptor while reading the entity from HttpResponse.", e);
			throw new FMSException(e);
		}
	}
482874
private HttpResponse init() throws HttpException {
		try {
			this.status = httpConnection.responseCode();
			this.in = (this.status < HttpStatus.HTTP_BAD_REQUEST) ? httpConnection.getInputStream() : httpConnection.getErrorStream();
		} catch (IOException e) {
			if (e instanceof FileNotFoundException) {
				// 服务器无返回内容，忽略之
			} else {
				throw new HttpException(e);
			}
		}

		try {
			this.headers = httpConnection.headers();
		} catch (IllegalArgumentException e) {
			StaticLog.warn(e, e.getMessage());
		}
		final Charset charset = httpConnection.getCharset();
		this.charsetFromResponse = charset;
		if (null != charset) {
			this.charset = charset;
		}

		if (null == this.in) {
			// 在一些情况下，返回的流为null，此时提供状态码说明
			this.in = new ByteArrayInputStream(StrUtil.format("Error request, response status: {}", this.status).getBytes());
		} else if (isGzip() && false == (in instanceof GZIPInputStream)) {
			try {
				in = new GZIPInputStream(in);
			} catch (IOException e) {
				// 在类似于Head等方法中无body返回，此时GZIPInputStream构造会出现错误，在此忽略此错误读取普通数据
				// ignore
			}
		} else if (isDeflate() && false == (in instanceof DeflaterInputStream)) {
			//Accept-Encoding: defalte
			in = new DeflaterInputStream(in);
		}

		// 同步情况下强制同步
		return this.isAsync ? this : forceSync();
	}
1139695
function _setResponseHeaders(headers) {
            this.responseHeaders = {};

            for (var header in headers) {
                if (headers.hasOwnProperty(header)) {
                    this.responseHeaders[header] = headers[header];
                }
            }

            if (this.async) {
                this._readyStateChange(IsotropyXMLHttpRequest.HEADERS_RECEIVED);
            } else {
                this.readyState = IsotropyXMLHttpRequest.HEADERS_RECEIVED;
            }
        }
51590
@Override
    public void setHeader(String name, String value) {
        this._getHttpServletResponse().setHeader(name, value);
    }