On Fri, May 8, 2009 at 5:49 PM, jpcook <jonathan.c...@erars.plus.com> wrote:
>
> Yes I can do it a bit later. I might even submit a patch :)
>
> When you say via URI do you mean something like:
> http://www.google.co.uk?httpClient.proxyName=host?httpClient.proxyPort=8080

Yeah but the httpClient prefix should not be needed. So tis
http://www.google.co.uk?proxyName=host&proxyPort=8080


We love contributions and patches. So please with your great findings
you should be able to grok that in the HttpComponent to set the proxy
as well.

there is a method you can use to get the parameters in HttpComponent
String proxyName = getAndRemoveParameter("proxyName", parameters);
String proxyPort = getAndRemoveParameter("proxyPort", parameters);

HttpComponent is the factory to create the http endpoint.


>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Good findings.
>>
>> Lets add the proxy options to camel-http so you can set it easily from the
>> URI.
>> Looks like the HostConfiguration object isnt easy to access currently.
>>
>> Do you mind creating a JIRA ticket for this?
>>
>> Link to JIRA from this page:
>> http://camel.apache.org/support.html
>>
>>
>>
>> On Fri, May 8, 2009 at 4:12 PM, jpcook <jonathan.c...@erars.plus.com>
>> wrote:
>>>
>>> I have successfully created a simple unit test testing a get using the
>>> apache
>>> http client without camel.
>>>
>>> public static void main(String[] args) {
>>>                // TODO Auto-generated method stub
>>>                HttpClient client = new HttpClient();
>>>        HttpMethod method = new GetMethod("http://www.google.co.uk";);
>>>
>>>        HostConfiguration config = client.getHostConfiguration();
>>>        config.setProxy(PROXY_HOST, PROXY_PORT);
>>>
>>>        try {
>>>            client.executeMethod(method);
>>>
>>>            if (method.getStatusCode() == HttpStatus.SC_OK) {
>>>                String response = method.getResponseBodyAsString();
>>>                System.out.println("Response = " + response);
>>>            }
>>>        } catch (IOException e) {
>>>            e.printStackTrace();
>>>        } finally {
>>>            method.releaseConnection();
>>>        }
>>>    }
>>>
>>> The above works nicely. However I'm struggling to put this back into my
>>> configure method with camel.
>>>
>>> public void configure() {
>>>                HttpClient client = new HttpClient();
>>>                client.getHostConfiguration().setProxy("PROXY_HOST",
>>> PROXY_PORT);
>>>                HttpEndpoint endpoint =
>>> context.getEndpoint("http://www.google.co.uk",HttpEndpoint.class);
>>>                BasicAuthenticationHttpClientConfigurer config = new
>>> BasicAuthenticationHttpClientConfigurer("","");
>>>                config.configureHttpClient(client);
>>>                endpoint.setHttpClientConfigurer(config);
>>>
>>>                from("direct:start")
>>>                .setHeader(HttpConstants.HTTP_METHOD,
>>> constant(org.apache.camel.component.http.HttpMethods.GET))
>>>                    .to("http://www.google.co.uk";).to("mock:results");
>>>            }
>>>
>>> The problem I have is that the setHttpClientConfigurer takes a
>>> HttpClientConfigurer which is an interface and the only implementation is
>>> the BasicAuthenticationHttpClientConfigurer which has to have a username
>>> and
>>> password which I don't require. I thought I could maybe hack around it
>>> above
>>> but it doesn't work.
>>>
>>> The question is should I create my own subclass of HttpClientConfigurer
>>> or
>>> am I going about this completely the wrong way? Or maybe it is better for
>>> me
>>> to write my own HttpProducer/Consumer or custom processor which would be
>>> a
>>> bit of a shame.
>>>
>>> Thanks
>>>
>>>
>>> jpcook wrote:
>>>>
>>>> And is it possible to get at the Apache HttpClient via the Camel Http
>>>> endpoint?
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> On Thu, May 7, 2009 at 6:37 PM, jpcook <jonathan.c...@erars.plus.com>
>>>>> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am playing around with the http endpoint in camel 2 and I thought a
>>>>>> good
>>>>>> starting point would be to run the testHttpGet() in
>>>>>> http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
>>>>>>
>>>>>> So nothing happens. It just hangs. I suspect this might be because I
>>>>>> need to
>>>>>> configure a proxy but I'm not sure how to do that and I can't find any
>>>>>> examples really apart from an old post but again it isn't clear to me.
>>>>>>
>>>>>> This is the configure method:
>>>>>> @Override
>>>>>>    protected RouteBuilder createRouteBuilder() throws Exception {
>>>>>>        return new RouteBuilder() {
>>>>>>            public void configure() {
>>>>>>                from("direct:start")
>>>>>>                .setHeader(HttpConstants.HTTP_METHOD,
>>>>>> constant(org.apache.camel.component.http.HttpMethods.GET))
>>>>>>                    .to("http://www.google.co.uk";).to("mock:results");
>>>>>>            }
>>>>>>        };
>>>>>>    }
>>>>>>
>>>>>> I also tried specifying the time out in the endpoint eg)
>>>>>> "http://www.google.co.uk?httpClient.soTimeout(5000)"
>>>>> You should set it with = as parameter, its like URI parameters.
>>>>> "http://www.google.co.uk?httpClient.soTimeout=5000";
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> But that didn't do anything. I wasn't sure if there was a way I could
>>>>>> at
>>>>>> least get something back.
>>>>>>
>>>>>> I've also read this useful page. Maybe it would be useful to have an
>>>>>> example
>>>>>> as most corporations will be using proxy servers.
>>>>>> http://camel.apache.org/http.html
>>>>> Yeah socket proxy in Java kinda sucks as you often need to set it with
>>>>> system properties.
>>>>>
>>>>> Maybe  the HTTP client have nice configuration for proxy. Feel free to
>>>>> look at Apache HTTP Client how to work with proxy.
>>>>> And report your findings, then we can improve Camel to ease the proxy
>>>>> configuration.
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Http-Endpoint-tp23430772p23430772.html
>>>>>> Sent from the Camel - Users (activemq) mailing list archive at
>>>>>> Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Open Source Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>> Apache Camel Reference Card:
>>>>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>>>> Interview with me:
>>>>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Http-Endpoint-tp23430772p23446776.html
>>> Sent from the Camel - Users (activemq) mailing list archive at
>>> Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>> Interview with me:
>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Http-Endpoint-tp23430772p23448297.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress

Reply via email to