public Producer createProducer() throws Exception { return new HttpProducer(this); }
if (getEndpoint().isBridgeEndpoint()) { exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE); String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); HttpMethod method = createMethod(exchange); Message in = exchange.getIn(); String httpProtocolVersion = in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class); HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy(); if (getEndpoint().getCookieHandler() != null) { Map<String, List<String>> cookieHeaders = getEndpoint().getCookieHandler().loadCookies(exchange, new URI(method.getURI().getEscapedURI())); for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) { String key = entry.getKey(); if (getEndpoint().isConnectionClose()) { method.addRequestHeader("Connection", "close"); int responseCode = executeMethod(method); LOG.debug("Http responseCode: {}", responseCode); populateResponse(exchange, method, in, strategy, responseCode); } else { boolean ok = HttpHelper.isStatusCodeOk(responseCode, getEndpoint().getOkStatusCodeRange()); if (ok) { populateResponse(exchange, method, in, strategy, responseCode); } else {
Map<String, String> headers = extractResponseHeaders(method.getResponseHeaders()); if (getEndpoint().getCookieHandler() != null) { Map<String, List<String>> m = new HashMap<>(); for (Entry<String, String> e : headers.entrySet()) { m.put(e.getKey(), Collections.singletonList(e.getValue())); getEndpoint().getCookieHandler().storeCookies(exchange, new URI(method.getURI().getEscapedURI()), m); Object responseBody = extractResponseBody(method, exchange, getEndpoint().isIgnoreResponseBody()); if (transferException && responseBody instanceof Exception) {
protected void populateResponse(Exchange exchange, HttpMethod method, Message in, HeaderFilterStrategy strategy, int responseCode) throws IOException, ClassNotFoundException, URISyntaxException { Object response = extractResponseBody(method, exchange, getEndpoint().isIgnoreResponseBody()); Message answer = exchange.getOut(); if (getEndpoint().getCookieHandler() != null) { getEndpoint().getCookieHandler().storeCookies(exchange, new URI(method.getURI().getEscapedURI()), m); if (getEndpoint().isCopyHeaders()) { MessageHelper.copyHeaders(exchange.getIn(), answer, httpProtocolHeaderFilterStrategy, false);
protected HttpMethod createMethod(Exchange exchange) throws Exception { String url = HttpHelper.createURL(exchange, getEndpoint()); URI uri = HttpHelper.createURI(exchange, url, getEndpoint()); String rewriteUrl = HttpHelper.urlRewrite(exchange, url, getEndpoint(), this); if (rewriteUrl != null) { RequestEntity requestEntity = createRequestEntity(exchange); String methodName = HttpHelper.createMethod(exchange, getEndpoint(), requestEntity != null).name(); HttpMethods methodsToUse = HttpMethods.valueOf(methodName); HttpMethod method = methodsToUse.createMethod(url); + ". If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: " + getEndpoint());
if (getEndpoint().getComponent().isAllowJavaSerializedObject() || getEndpoint().isTransferException()) { return HttpHelper.deserializeJavaObjectFromStream(is, exchange.getContext()); } else { if (!getEndpoint().isDisableStreamCache()) { response = doExtractResponseBodyAsStream(is, exchange);
if (!getEndpoint().getComponent().isAllowJavaSerializedObject()) { throw new CamelExchangeException("Content-type " + HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT + " is not allowed", exchange);