codegist/crest — Issue #8: proxy
Author: priedl
Created: 2011-10-18 13:38:29+00:00
State: open

hi,

i am using the brand new version 2.0.0 of CREST and i have a question concerning the http-header parameter "Proxy-Authorization". i configured my crest service to use a proxy that needs authorization. every call results in a 407 (proxy-authorization required) because the calls don't contain the header parameter "Proxy-Authorization". for GET calls there seems to be some automatic retry mechanism (i did not specify a custom retryhandler) and therefore the second (automatically sent) request contains the necessary header and works fine (200). for POST calls it doesn't work that way. whenever i send a POST request via the proxy my errorhandler receives the following exception:

org.codegist.crest.io.RequestException: org.apache.http.client.ClientProtocolException
at org.codegist.crest.io.http.HttpRequestExecutor.execute(HttpRequestExecutor.java:83)
at org.codegist.crest.io.RetryingRequestExecutor.execute(RetryingRequestExecutor.java:52)
at org.codegist.crest.DefaultCRest$CRestInvocationHandler.doInvoke(DefaultCRest.java:81)
at org.codegist.common.reflect.ObjectMethodsAwareInvocationHandler.invoke(ObjectMethodsAwareInvocationHandler.java:42)
at org.codegist.common.reflect.JdkProxyFactory$DelegatorHandler.invoke(JdkProxyFactory.java:50)
at $Proxy12.extendedStatus(Native Method)
at at.sesame.fhooe.lib.pms.model.ControllableDevice.getExtendedStatus(ControllableDevice.java:64)
at at.sesame.fhooe.pms.PMSClientActivity.onClick(PMSClientActivity.java:329)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at org.codegist.crest.io.http.HttpClientHttpChannel.send(HttpClientHttpChannel.java:81)
at org.codegist.crest.io.http.HttpRequestExecutor.doExecute(HttpRequestExecutor.java:148)
at org.codegist.crest.io.http.HttpRequestExecutor.execute(HttpRequestExecutor.java:77)
... 18 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:413)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
... 23 more

i also tried to manually set the necessary header like this:

@POST
@Path("/{mac}/extended-status")
@EntityWriter(PMSEntityWriter.class)
@Produces("application/json")
public ExtendedPMSStatus extendedStatus(@PathParam("mac")String _mac,
@FormParam("user")String _user,
@FormParam("password") String password
,@HeaderParam("Proxy-Authorization") String _auth);

which results in the following exception:

org.codegist.crest.io.RequestException: Length Required
at org.codegist.crest.io.http.HttpRequestExecutor.execute(HttpRequestExecutor.java:79)
at org.codegist.crest.io.RetryingRequestExecutor.execute(RetryingRequestExecutor.java:52)
at org.codegist.crest.DefaultCRest$CRestInvocationHandler.doInvoke(DefaultCRest.java:81)
at org.codegist.common.reflect.ObjectMethodsAwareInvocationHandler.invoke(ObjectMethodsAwareInvocationHandler.java:42)
at org.codegist.common.reflect.JdkProxyFactory$DelegatorHandler.invoke(JdkProxyFactory.java:50)
at $Proxy13.extendedStatus(Native Method)
at at.sesame.fhooe.lib.pms.model.ControllableDevice.getExtendedStatus(ControllableDevice.java:64)
at at.sesame.fhooe.pms.PMSClientActivity.onClick(PMSClientActivity.java:329)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

i don't think that the problem is in the proxy, because GET calls work fine (the correct credentials can be extracted). do you have any hints on how to solve my problem?

tia and regards,
peter