简体   繁体   English

为什么需要额外的步骤使用 http.proxyHost apache 骆驼 http 组件

[英]Why need extra step by using http.proxyHost for apache camel http component

By using http.proxyHost for apache camel http component.通过使用 http.proxyHost 为 apache 骆驼 http 组件。 It need two steps below, otherwise http.proxy will not work for camel http component.它需要以下两个步骤,否则 http.proxy 将无法用于 camel http 组件。

  1. put -Dhttp.proxyHost at java command line将 -Dhttp.proxyHost 放在 java 命令行

  2. at camel http query paramter, setting useSystemProperties to true在骆驼 http 查询参数中,将 useSystemProperties 设置为 true

but for javax.net.ssl.trustStore, step 2 is not need.但对于 javax.net.ssl.trustStore,不需要第 2 步。

Since both of them(trustStore or httpProxy) are system properties could be used via java command line.由于它们(trustStore 或 httpProxy)都是系统属性,可以通过 java 命令行使用。 Why http.proxyHost need step2, but javax.net.ssl.trustStore does not?为什么http.proxyHost需要step2,而javax.net.ssl.trustStore不需要? Could anyone have some idea?任何人都可以有一些想法吗?

Thanks in advancace!提前致谢!

Apache Camel HTTP component provide a per URI / Endpoint way of configuring an HTTP proxy: Apache Camel HTTP组件提供了一种配置 HTTP 代理的每个 URI/端点方式:

from("direct:start")
    .to("http://somehost?proxyAuthHost=www.someproxy.com&proxyAuthPort=80");

Adds to that a way to override proxy configuration using a context global options:添加一种使用上下文全局选项覆盖代理配置的方法:

context.getGlobalOptions().put("http.proxyHost", "someproxy");
context.getGlobalOptions().put("http.proxyPort", "someport");

This allows the org.apache.http.client.HttpClient to be consider configuration precedence when resolving and creating the HTTP proxy:这允许org.apache.http.client.HttpClient在解析和创建 HTTP 代理时考虑配置优先级:

  • If the system properties (for the HTTP proxy) are there those will be resolved and loaded如果系统属性(对于 HTTP 代理)在那里,那些将被解析和加载
  • If the HTTP proxy global options are there, those will be resolved and used instead of system properties如果存在 HTTP 代理全局选项,则将解析并使用这些选项而不是系统属性
  • If an endpoint HTTP proxy configuration has been set then this configuration will be resolved and used如果已设置端点 HTTP 代理配置,则将解析并使用此配置

All of the configuration resolution steps can be skipped altogether to fallback on using all HTTP(S) related properties (within the underlying org.apache.http.client.HttpClient ) from the system properties if the user wishes so by setting the useSystemProperties component option.如果用户希望通过设置useSystemProperties组件选项,则可以完全跳过所有配置解析步骤以回退使用系统属性中的所有 HTTP(S) 相关属性(在底层org.apache.http.client.HttpClient )。

As a summary, you can think of the HTTP related properties resolution process as providing a set of flexible configuration options to the user to fit in all use cases.总而言之,您可以将 HTTP 相关属性解析过程视为为用户提供一组灵活的配置选项以适应所有用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM