HttpComponent + Redirect

View: New views
8 Messages — Rating Filter:   Alert me  

HttpComponent + Redirect

by KnisterPeter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

I would like to write a unit test that verifies that our services
processor returns an expected redirect after processing. But the
httpclient always implicitly redirects and returns that result.

Is there a way to force the http-client endpoint to do not redirect but
set the http-status header and the location header?

Thanks
Markus Wolf
- --
NMMN - New Media Markets & Networks GmbH
Langbehnstrasse 6, 22761 Hamburg
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82

http://www.nmmn.com
Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
Softwareentwicklung LLynch: -720
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkr0Hp0ACgkQDBHISU1oEKGx0wCfSRKb0LTFNCwRvtU6gzZGmDwd
D4UAniVr5FKCf6OpAOoObTuExVsNL3YG
=hCB6
-----END PGP SIGNATURE-----

Re: HttpComponent + Redirect

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 6, 2009 at 2:03 PM, Markus Wolf <markus.wolf@...> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi there,
>
> I would like to write a unit test that verifies that our services
> processor returns an expected redirect after processing. But the
> httpclient always implicitly redirects and returns that result.
>
> Is there a way to force the http-client endpoint to do not redirect but
> set the http-status header and the location header?
>

I think you can configure the Apache Commons HTTP client to follow
redirects or not.
And you can configure the camel http endpoint to throw exception or
not if status != 200

throwException=true|false


> Thanks
> Markus Wolf
> - --
> NMMN - New Media Markets & Networks GmbH
> Langbehnstrasse 6, 22761 Hamburg
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
> HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82
>
> http://www.nmmn.com
> Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
> Softwareentwicklung LLynch: -720
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkr0Hp0ACgkQDBHISU1oEKGx0wCfSRKb0LTFNCwRvtU6gzZGmDwd
> D4UAniVr5FKCf6OpAOoObTuExVsNL3YG
> =hCB6
> -----END PGP SIGNATURE-----
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: HttpComponent + Redirect

by KnisterPeter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Claus,

> I would like to write a unit test that verifies that our services
> processor returns an expected redirect after processing. But the
> httpclient always implicitly redirects and returns that result.
>
> Is there a way to force the http-client endpoint to do not redirect but
> set the http-status header and the location header?
>
>
>> I think you can configure the Apache Commons HTTP client to follow
>> redirects or not.
>> And you can configure the camel http endpoint to throw exception or
>> not if status != 200
>
>> throwException=true|false
>
thanks for that ideas. I already got a solution I found acceptable.
I do redirect to another endpoint configured in the test setup and
verify that the request ends there.

Regards
Markus Wolf
- --
NMMN - New Media Markets & Networks GmbH
Langbehnstrasse 6, 22761 Hamburg
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82

http://www.nmmn.com
Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
Softwareentwicklung LLynch: -720
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkr0JTgACgkQDBHISU1oEKG9TwCePU2R/gk6AvERsAYgQEK6snaT
1WcAn3LIxTQ+wbPMVeaQH1Q99Sknpedv
=Mn/C
-----END PGP SIGNATURE-----

Re: HttpComponent + Redirect

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Please try to set http endpoint uri like this
http://www.example.com/example?httpClient.http.protocol.handle-redirects=false
You can dig the HttpClient's document[1] for more information.

[1]http://hc.apache.org/httpcomponents-client/tutorial/html/httpagent.html#d4e1015

Willem

Markus Wolf wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi there,
>
> I would like to write a unit test that verifies that our services
> processor returns an expected redirect after processing. But the
> httpclient always implicitly redirects and returns that result.
>
> Is there a way to force the http-client endpoint to do not redirect but
> set the http-status header and the location header?
>
> Thanks
> Markus Wolf
> - --
> NMMN - New Media Markets & Networks GmbH
> Langbehnstrasse 6, 22761 Hamburg
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
> HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82
>
> http://www.nmmn.com
> Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
> Softwareentwicklung LLynch: -720
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkr0Hp0ACgkQDBHISU1oEKGx0wCfSRKb0LTFNCwRvtU6gzZGmDwd
> D4UAniVr5FKCf6OpAOoObTuExVsNL3YG
> =hCB6
> -----END PGP SIGNATURE-----
>


Re: HttpComponent + Redirect

by KnisterPeter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Willem,

> Please try to set http endpoint uri like this
> http://www.example.com/example?httpClient.http.protocol.handle-redirects=false
>
this results in the following exception:

org.apache.camel.ResolveEndpointFailedException: Failed to resolve
endpoint:
http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
due to: Failed to resolve endpoint:
http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
due to: There are 1 parameters that couldn't be set on the endpoint.
Check the uri if the parameters are spelt correctly and that they are
properties of the endpoint. Unknown
parameters=[{http.protocol.handle-redirects=false}]
        at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:414)
        at
org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:402)
        at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:87)
        at
org.apache.camel.impl.DefaultProducerTemplate.request(DefaultProducerTemplate.java:262)
        at
de.llynch.esb.tracker.LinkTrackerImplTest.testLinkClickWithParameters(LinkTrackerImplTest.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
        at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
        at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
        at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
        at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
        at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
        at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
        at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
        at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
        at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
        at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
        at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
        at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
due to: There are 1 parameters that couldn't be set on the endpoint.
Check the uri if the parameters are spelt correctly and that they are
properties of the endpoint. Unknown
parameters=[{http.protocol.handle-redirects=false}]
        at
org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:115)
        at
org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:117)
        at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:79)
        at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:394)
        ... 26 more




This behaviour is caused, because there is not javabean setter for the
property in the HttpClientParam class.

But thanks anyway :)


> You can dig the HttpClient's document[1] for more information.
>
> [1]http://hc.apache.org/httpcomponents-client/tutorial/html/httpagent.html#d4e1015
>
>
> Willem
>
> Markus Wolf wrote:
> Hi there,
>
> I would like to write a unit test that verifies that our services
> processor returns an expected redirect after processing. But the
> httpclient always implicitly redirects and returns that result.
>
> Is there a way to force the http-client endpoint to do not redirect but
> set the http-status header and the location header?
>
> Thanks
> Markus Wolf
>>

- --
NMMN - New Media Markets & Networks GmbH
Langbehnstrasse 6, 22761 Hamburg
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82

http://www.nmmn.com
Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
Softwareentwicklung LLynch: -720
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkr0KFUACgkQDBHISU1oEKFeGgCgm7cs3uxYQRN2ggJQTg1R38at
76gAnRKYtHE8LEO680+Kp/RD4BkYjHbs
=cxyP
-----END PGP SIGNATURE-----

Re: HttpComponent + Redirect

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, camel-http component doesn't support to take the
parameter like "http.protocol.handle-redirects".

After digging the code for a while, I think I can do some enhancement on
the camel-http endpoint this weekend :)

Willem

Markus Wolf wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Willem,
>
>> Please try to set http endpoint uri like this
>> http://www.example.com/example?httpClient.http.protocol.handle-redirects=false
>>
> this results in the following exception:
>
> org.apache.camel.ResolveEndpointFailedException: Failed to resolve
> endpoint:
> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
> due to: Failed to resolve endpoint:
> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
> due to: There are 1 parameters that couldn't be set on the endpoint.
> Check the uri if the parameters are spelt correctly and that they are
> properties of the endpoint. Unknown
> parameters=[{http.protocol.handle-redirects=false}]
> at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:414)
> at
> org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:402)
> at
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:87)
> at
> org.apache.camel.impl.DefaultProducerTemplate.request(DefaultProducerTemplate.java:262)
> at
> de.llynch.esb.tracker.LinkTrackerImplTest.testLinkClickWithParameters(LinkTrackerImplTest.java:62)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
> at
> org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
> at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
> at
> org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
> at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
> at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
> at
> org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
> at
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
> at
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
> at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
> at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> at
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint:
> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
> due to: There are 1 parameters that couldn't be set on the endpoint.
> Check the uri if the parameters are spelt correctly and that they are
> properties of the endpoint. Unknown
> parameters=[{http.protocol.handle-redirects=false}]
> at
> org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:115)
> at
> org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:117)
> at
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:79)
> at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:394)
> ... 26 more
>
>
>
>
> This behaviour is caused, because there is not javabean setter for the
> property in the HttpClientParam class.
>
> But thanks anyway :)
>
>
>> You can dig the HttpClient's document[1] for more information.
>>
>> [1]http://hc.apache.org/httpcomponents-client/tutorial/html/httpagent.html#d4e1015
>>
>>
>> Willem
>>
>> Markus Wolf wrote:
>> Hi there,
>>
>> I would like to write a unit test that verifies that our services
>> processor returns an expected redirect after processing. But the
>> httpclient always implicitly redirects and returns that result.
>>
>> Is there a way to force the http-client endpoint to do not redirect but
>> set the http-status header and the location header?
>>
>> Thanks
>> Markus Wolf
>
> - --
> NMMN - New Media Markets & Networks GmbH
> Langbehnstrasse 6, 22761 Hamburg
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
> HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82
>
> http://www.nmmn.com
> Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
> Softwareentwicklung LLynch: -720
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkr0KFUACgkQDBHISU1oEKFeGgCgm7cs3uxYQRN2ggJQTg1R38at
> 76gAnRKYtHE8LEO680+Kp/RD4BkYjHbs
> =cxyP
> -----END PGP SIGNATURE-----
>


Re: HttpComponent + Redirect

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I checked the code of http client 3.1, there is no parameter key of
"http.protocol.handle-redirects".
This option is part of client 4.0.
Maybe we should consider to upgrade camel-http to use httpclient 4.0.

Willem

Willem Jiang wrote:

> Oh, camel-http component doesn't support to take the
> parameter like "http.protocol.handle-redirects".
>
> After digging the code for a while, I think I can do some enhancement on
> the camel-http endpoint this weekend :)
>
> Willem
>
> Markus Wolf wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi Willem,
>>
>>> Please try to set http endpoint uri like this
>>> http://www.example.com/example?httpClient.http.protocol.handle-redirects=false 
>>>
>>>
>> this results in the following exception:
>>
>> org.apache.camel.ResolveEndpointFailedException: Failed to resolve
>> endpoint:
>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2 
>>
>> due to: Failed to resolve endpoint:
>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2 
>>
>> due to: There are 1 parameters that couldn't be set on the endpoint.
>> Check the uri if the parameters are spelt correctly and that they are
>> properties of the endpoint. Unknown
>> parameters=[{http.protocol.handle-redirects=false}]
>>     at
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:414)
>>
>>     at
>> org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:402)
>>
>>     at
>> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:87)
>>
>>     at
>> org.apache.camel.impl.DefaultProducerTemplate.request(DefaultProducerTemplate.java:262)
>>
>>     at
>> de.llynch.esb.tracker.LinkTrackerImplTest.testLinkClickWithParameters(LinkTrackerImplTest.java:62)
>>
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>     at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
>>     at
>> org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
>>
>>     at
>> org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
>>     at
>> org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
>>
>>     at
>> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
>>     at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
>>     at
>> org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
>>
>>     at
>> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>>
>>     at
>> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>>
>>     at
>> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>>
>>     at
>> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>>     at
>> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>>
>>     at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>
>> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
>> resolve endpoint:
>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2 
>>
>> due to: There are 1 parameters that couldn't be set on the endpoint.
>> Check the uri if the parameters are spelt correctly and that they are
>> properties of the endpoint. Unknown
>> parameters=[{http.protocol.handle-redirects=false}]
>>     at
>> org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:115)
>>
>>     at
>> org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:117)
>>
>>     at
>> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:79)
>>
>>     at
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:394)
>>
>>     ... 26 more
>>
>>
>>
>>
>> This behaviour is caused, because there is not javabean setter for the
>> property in the HttpClientParam class.
>>
>> But thanks anyway :)
>>
>>
>>> You can dig the HttpClient's document[1] for more information.
>>>
>>> [1]http://hc.apache.org/httpcomponents-client/tutorial/html/httpagent.html#d4e1015 
>>>
>>>
>>>
>>> Willem
>>>
>>> Markus Wolf wrote:
>>> Hi there,
>>>
>>> I would like to write a unit test that verifies that our services
>>> processor returns an expected redirect after processing. But the
>>> httpclient always implicitly redirects and returns that result.
>>>
>>> Is there a way to force the http-client endpoint to do not redirect but
>>> set the http-status header and the location header?
>>>
>>> Thanks
>>> Markus Wolf
>>
>> - --
>> NMMN - New Media Markets & Networks GmbH
>> Langbehnstrasse 6, 22761 Hamburg
>> Geschäftsführung: Kfm. Michael Schütt
>> Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
>> HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82
>>
>> http://www.nmmn.com
>> Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
>> Softwareentwicklung LLynch: -720
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkr0KFUACgkQDBHISU1oEKFeGgCgm7cs3uxYQRN2ggJQTg1R38at
>> 76gAnRKYtHE8LEO680+Kp/RD4BkYjHbs
>> =cxyP
>> -----END PGP SIGNATURE-----
>>
>
>



Re: HttpComponent + Redirect

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 10:46 AM, Willem Jiang <willem.jiang@...> wrote:
> I checked the code of http client 3.1, there is no parameter key of
> "http.protocol.handle-redirects".
> This option is part of client 4.0.
> Maybe we should consider to upgrade camel-http to use httpclient 4.0.
>

Yeah sometime after Camel 2.1 as we should keep camel-http stable as
3.1 vs 4.0 is a lot changed in the API.
There is already a ticket about this upgrade.


> Willem
>
> Willem Jiang wrote:
>>
>> Oh, camel-http component doesn't support to take the
>> parameter like "http.protocol.handle-redirects".
>>
>> After digging the code for a while, I think I can do some enhancement on
>> the camel-http endpoint this weekend :)
>>
>> Willem
>>
>> Markus Wolf wrote:
>>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Hi Willem,
>>>
>>>> Please try to set http endpoint uri like this
>>>>
>>>> http://www.example.com/example?httpClient.http.protocol.handle-redirects=false
>>>>
>>> this results in the following exception:
>>>
>>> org.apache.camel.ResolveEndpointFailedException: Failed to resolve
>>> endpoint:
>>>
>>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
>>> due to: Failed to resolve endpoint:
>>>
>>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
>>> due to: There are 1 parameters that couldn't be set on the endpoint.
>>> Check the uri if the parameters are spelt correctly and that they are
>>> properties of the endpoint. Unknown
>>> parameters=[{http.protocol.handle-redirects=false}]
>>>    at
>>>
>>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:414)
>>>    at
>>>
>>> org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:402)
>>>    at
>>>
>>> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:87)
>>>    at
>>>
>>> org.apache.camel.impl.DefaultProducerTemplate.request(DefaultProducerTemplate.java:262)
>>>    at
>>>
>>> de.llynch.esb.tracker.LinkTrackerImplTest.testLinkClickWithParameters(LinkTrackerImplTest.java:62)
>>>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>    at
>>>
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>    at
>>>
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>    at java.lang.reflect.Method.invoke(Method.java:597)
>>>    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
>>>    at
>>>
>>> org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
>>>    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
>>>    at
>>>
>>> org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
>>>    at
>>> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
>>>    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
>>>    at
>>>
>>> org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
>>>    at
>>>
>>> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>>>    at
>>>
>>> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>>>    at
>>>
>>> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>>>    at
>>> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>>>    at
>>>
>>> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>>    at
>>>
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
>>> resolve endpoint:
>>>
>>> http://127.0.0.1:8888/track-link?e=1&httpClient.http.protocol.handle-redirects=false&l=2
>>> due to: There are 1 parameters that couldn't be set on the endpoint.
>>> Check the uri if the parameters are spelt correctly and that they are
>>> properties of the endpoint. Unknown
>>> parameters=[{http.protocol.handle-redirects=false}]
>>>    at
>>>
>>> org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:115)
>>>    at
>>>
>>> org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:117)
>>>    at
>>>
>>> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:79)
>>>    at
>>>
>>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:394)
>>>    ... 26 more
>>>
>>>
>>>
>>>
>>> This behaviour is caused, because there is not javabean setter for the
>>> property in the HttpClientParam class.
>>>
>>> But thanks anyway :)
>>>
>>>
>>>> You can dig the HttpClient's document[1] for more information.
>>>>
>>>>
>>>> [1]http://hc.apache.org/httpcomponents-client/tutorial/html/httpagent.html#d4e1015
>>>>
>>>>
>>>> Willem
>>>>
>>>> Markus Wolf wrote:
>>>> Hi there,
>>>>
>>>> I would like to write a unit test that verifies that our services
>>>> processor returns an expected redirect after processing. But the
>>>> httpclient always implicitly redirects and returns that result.
>>>>
>>>> Is there a way to force the http-client endpoint to do not redirect but
>>>> set the http-status header and the location header?
>>>>
>>>> Thanks
>>>> Markus Wolf
>>>
>>> - --
>>> NMMN - New Media Markets & Networks GmbH
>>> Langbehnstrasse 6, 22761 Hamburg
>>> Geschäftsführung: Kfm. Michael Schütt
>>> Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
>>> HypoVereinsbank   -   BLZ 200 300 00   -   Konto-Nr. 156 29 82
>>>
>>> http://www.nmmn.com
>>> Tel.: +49 40 284 118-0  -  Fax: +49 40 284118-999
>>> Softwareentwicklung LLynch: -720
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.9 (GNU/Linux)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>
>>> iEYEARECAAYFAkr0KFUACgkQDBHISU1oEKFeGgCgm7cs3uxYQRN2ggJQTg1R38at
>>> 76gAnRKYtHE8LEO680+Kp/RD4BkYjHbs
>>> =cxyP
>>> -----END PGP SIGNATURE-----
>>>
>>
>>
>
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Need professional support or training for Apache Camel? Graphic Design by Hiram and the Nabble Forum configured by James