koush / ion

Android Asynchronous Networking and Image Loading
Other
6.29k stars 1.03k forks source link

Request is forbidden by WinProxy #429

Open minhanhhere opened 9 years ago

minhanhhere commented 9 years ago

Hi,

I'm using Ion via gradle with this dependency:

compile 'com.koushikdutta.ion:ion:2.+'

I'm using GenyMotion to test my app. In my app I make a simple image request:

ImageView imageView = (ImageView) rootView.findViewById(R.id.image_view);
Ion.with(imageView).load("http://i.imgur.com/DvpvklR.png");

The request is forbidden. My network (in my office) is under a Win Proxy and it is already configured in Wifi settings

Using picasso, I can load the image normally:

Picasso.with(getActivity()).load("http://i.imgur.com/DvpvklR.png").into(imageView);
minhanhhere commented 9 years ago

To add more information, I already tried to use proxy in my request

String resp = Ion.with(getActivity())
                        .load("http://example.com/")
                        .proxy("10.0.0.5", 8080)
                        .setLogging("ION", Log.DEBUG)
                        .asString()
                        .get();

but it does not help. Using the proxy host/port in System.properties does not help, too.

I have not try to test it under a real device because my office does not offer Wifi. I hope this error occurs in GenyMotion only.

fbis251 commented 9 years ago

It may just be your proxy, I have successfully loaded requests with ION using mitmproxy, charles proxy and burp without issues.

Do you know whether the proxy is running in transparent mode? You can probably check your requests using the browser of the computer you're using, or maybe even trying to run one of the three proxies on the computer while testing with ION and Genymotion

minhanhhere commented 9 years ago

Hello fbis251,

I try one of your three suggestion Proxies and ION works, for sure.

But I just wonder about the case of Picasso. It can bypass WinProxy without any config. Is there any different in the way these 2 library work?

fbis251 commented 9 years ago

I haven't tested Picasso with a proxy so I wouldn't be able to say.

koush commented 9 years ago

If you can get full logs from winproxy and ion that would be helpful. I usually test with CharlesProxy.

minhanhhere commented 9 years ago

It was a long time since this issue opened and today I check Ion in the same environment (winproxy). I found the bug only happen with "http" image. In case, "https" work fine.

Here is the FAILED log for a "http" image

04-17 11:45:21.236    2957-2957/com.mak.myapplication D/IonLogs﹕ (0 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: preparing request
04-17 11:45:21.236    2957-2957/com.mak.myapplication D/IonLogs﹕ (0 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: preparing request
04-17 11:45:21.236    2957-2957/com.mak.myapplication I/IonLogs﹕ (0 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Using loader: com.koushikdutta.ion.loader.HttpLoader@52a97c24
04-17 11:45:21.240    2957-2971/com.mak.myapplication D/IonLogs﹕ (0 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Executing request.
04-17 11:45:21.252    2957-2971/com.mak.myapplication D/IonLogs﹕ (11 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Connecting socket
04-17 11:45:21.252    2957-2971/com.mak.myapplication V/IonLogs﹕ (11 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Using proxy: 192.168.203.2:8080
04-17 11:45:21.256    2957-2971/com.mak.myapplication V/IonLogs﹕ (16 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: socket connected
04-17 11:45:21.272    2957-2971/com.mak.myapplication V/IonLogs﹕ (31 ms) http://vnreview.vn/image/13/98/08/1398082.jpg:
    GET /image/13/98/08/1398082.jpg HTTP/1.1
    Host: vnreview.vn
    User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; Google Galaxy Nexus - 4.3 - API 18 - 720x1280 Build/JLS36G)
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Accept: */*
04-17 11:45:21.272    2957-2971/com.mak.myapplication V/IonLogs﹕ (31 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: request completed
04-17 11:45:21.296    2957-2971/com.mak.myapplication V/IonLogs﹕ (52 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Received headers:
    HTTP/1.0 403 Forbidden
    Proxy-agent: BlueCoat-WinProxy
    Connection: close
    Pragma: no-cache
    Cache-Control: no-cache
    Content-Type: text/html
    Content-Encoding: 7bit
    Content-Length: 163
04-17 11:45:21.296    2957-2971/com.mak.myapplication D/IonLogs﹕ (54 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Response is not cacheable
04-17 11:45:21.296    2957-2971/com.mak.myapplication V/IonLogs﹕ (55 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Final (post cache response) headers:
    HTTP/1.0 403 Forbidden
    Proxy-agent: BlueCoat-WinProxy
    Connection: close
    Pragma: no-cache
    Cache-Control: no-cache
    Content-Type: text/html
    Content-Encoding: 7bit
    Content-Length: 163
04-17 11:45:21.300    2957-2971/com.mak.myapplication D/IonLogs﹕ (55 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: Connection successful
04-17 11:45:21.300    2957-2971/com.mak.myapplication V/IonLogs﹕ (58 ms) http://vnreview.vn/image/13/98/08/1398082.jpg: closing out socket (not keep alive)

And here is the log for the SUCCESSFULL "https" image

04-17 11:47:50.280    3094-3094/? D/IonLogs﹕ (0 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: preparing request
04-17 11:47:50.280    3094-3094/? D/IonLogs﹕ (0 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: preparing request
04-17 11:47:50.288    3094-3094/? I/IonLogs﹕ (0 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Using loader: com.koushikdutta.ion.loader.HttpLoader@52a80910
04-17 11:47:50.288    3094-3108/? D/IonLogs﹕ (0 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Executing request.
04-17 11:47:50.292    3094-3108/? D/IonLogs﹕ (3 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Connecting socket
04-17 11:47:50.292    3094-3108/? V/IonLogs﹕ (3 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Using proxy: 192.168.203.2:8080
04-17 11:47:50.292    3094-3108/? V/IonLogs﹕ (5 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Proxying: CONNECT photo.tinhte.vn:443 HTTP/1.1
    Host: photo.tinhte.vn
04-17 11:47:50.296    3094-3108/? V/IonLogs﹕ (11 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: HTTP/1.0 200 Connection established
04-17 11:47:50.296    3094-3108/? V/IonLogs﹕ (11 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Proxy-agent: WinProxy-Ver6.0 R1c
04-17 11:47:50.296    3094-3108/? V/IonLogs﹕ (11 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Connection: close
04-17 11:47:50.296    3094-3108/? V/IonLogs﹕ (11 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg:
04-17 11:47:50.740    3094-3108/? V/IonLogs﹕ (452 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: checking spdy handshake
04-17 11:47:50.740    3094-3108/? V/IonLogs﹕ (452 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: socket connected
04-17 11:47:50.740    3094-3108/? V/IonLogs﹕ (453 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg:
    GET /store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg HTTP/1.1
    Host: photo.tinhte.vn
    User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; Google Galaxy Nexus - 4.3 - API 18 - 720x1280 Build/JLS36G)
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Accept: */*
04-17 11:47:50.744    3094-3108/? V/IonLogs﹕ (453 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: request completed
04-17 11:47:50.784    3094-3108/? V/IonLogs﹕ (495 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Received headers:
    HTTP/1.1 200 OK
    Date: Fri, 17 Apr 2015 04:47:20 GMT
    Server: LiteSpeed
    Accept-Ranges: bytes
    Connection: Keep-Alive
    Keep-Alive: timeout=5, max=100
    ETag: "1d9c1-553062ec-ade9fff35d077176"
    Last-Modified: Fri, 17 Apr 2015 01:33:32 GMT
    Content-Type: image/jpeg
    Content-Length: 121281
    Vary: User-Agent
    Cache-Control: public, max-age=2592000
    Expires: Sun, 17 May 2015 04:47:20 GMT
04-17 11:47:50.784    3094-3108/? D/IonLogs﹕ (496 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Caching response
04-17 11:47:50.792    3094-3108/? V/IonLogs﹕ (501 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Final (post cache response) headers:
    HTTP/1.1 200 OK
    Date: Fri, 17 Apr 2015 04:47:20 GMT
    Server: LiteSpeed
    Accept-Ranges: bytes
    Connection: Keep-Alive
    Keep-Alive: timeout=5, max=100
    ETag: "1d9c1-553062ec-ade9fff35d077176"
    Last-Modified: Fri, 17 Apr 2015 01:33:32 GMT
    Content-Type: image/jpeg
    Content-Length: 121281
    Vary: User-Agent
    Cache-Control: public, max-age=2592000
    Expires: Sun, 17 May 2015 04:47:20 GMT
04-17 11:47:50.792    3094-3108/? D/IonLogs﹕ (502 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Connection successful
04-17 11:47:50.856    3094-3108/? D/IonLogs﹕ (571 ms) https://photo.tinhte.vn/store/2015/04/3020946_Tinhte.vn_Nokia_N1.jpg: Recycling keep-alive socket

Thanks all.