{"action":"created","issue":{"url":"https://api.github.com/repos/square/okhttp/issues/2900","repository_url":"https://api.github.com/repos/square/okhttp","labels_url":"https://api.github.com/repos/square/okhttp/issues/2900/labels{/name}","comments_url":"https://api.github.com/repos/square/okhttp/issues/2900/comments","events_url":"https://api.github.com/repos/square/okhttp/issues/2900/events","html_url":"https://github.com/square/okhttp/issues/2900","id":182197736,"number":2900,"title":"SSL-Connection via Proxy with Authentcation fails","user":{"login":"ja-fra","id":1815139,"avatar_url":"https://avatars.githubusercontent.com/u/1815139?v=3","gravatar_id":"","url":"https://api.github.com/users/ja-fra","html_url":"https://github.com/ja-fra","followers_url":"https://api.github.com/users/ja-fra/followers","following_url":"https://api.github.com/users/ja-fra/following{/other_user}","gists_url":"https://api.github.com/users/ja-fra/gists{/gist_id}","starred_url":"https://api.github.com/users/ja-fra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ja-fra/subscriptions","organizations_url":"https://api.github.com/users/ja-fra/orgs","repos_url":"https://api.github.com/users/ja-fra/repos","events_url":"https://api.github.com/users/ja-fra/events{/privacy}","received_events_url":"https://api.github.com/users/ja-fra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-11T08:03:17Z","updated_at":"2016-10-12T06:43:21Z","closed_at":null,"body":"The following simple request via a Proxy that requires Authentication fails:\r\n```#!java\r\nfinal Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(\"localhost\", 8001));\r\nfinal Response response = new OkHttpClient.Builder()\r\n        .proxy(proxy)\r\n        .proxyAuthenticator(new Authenticator() {\r\n            @Override\r\n            public Request authenticate(Route route, Response response) throws IOException {\r\n                String credential = Credentials.basic(\"proxyuser\", \"proxypass\");\r\n                return response.request().newBuilder()\r\n                        .header(\"Proxy-Authorization\", credential)\r\n                        .build();                        \r\n            }\r\n        })\r\n        .build()\r\n        .newCall(new Request.Builder()\r\n                .get()\r\n                .url(\"https://www.google.com/\")\r\n                .build())\r\n        .execute();\r\n```\r\nwith the following error:\r\n```\r\nCaused by: java.net.ProtocolException: Unexpected status line: <html>\r\n\tat okhttp3.internal.http.StatusLine.parse(StatusLine.java:69)\r\n\tat okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186)\r\n\tat okhttp3.internal.connection.RealConnection.createTunnel(RealConnection.java:296)\r\n\tat okhttp3.internal.connection.RealConnection.buildTunneledConnection(RealConnection.java:155)\r\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.java:111)\r\n\tat okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:193)\r\n\tat okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)\r\n\tat okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)\r\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)\r\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)\r\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)\r\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)\r\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)\r\n\tat okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)\r\n\tat okhttp3.RealCall.execute(RealCall.java:60)\r\n```\r\n\r\nThe same request via a Proxy _without_ Authentication works fine, as does a Non-SSL request via Proxy with Authentication.\r\n\r\nThe issue came up while debugging googlemaps/google-maps-services-java#190. Both, v2.7.5 and v3.4.1 show the same behaviour.\r\n\r\nFor testing, I'm using [mitmproxy](https://mitmproxy.org/) with the following parameters: `mitmproxy -p 8001 --singleuser proxyuser:proxypass`"},"comment":{"url":"https://api.github.com/repos/square/okhttp/issues/comments/253132438","html_url":"https://github.com/square/okhttp/issues/2900#issuecomment-253132438","issue_url":"https://api.github.com/repos/square/okhttp/issues/2900","id":253132438,"user":{"login":"ja-fra","id":1815139,"avatar_url":"https://avatars.githubusercontent.com/u/1815139?v=3","gravatar_id":"","url":"https://api.github.com/users/ja-fra","html_url":"https://github.com/ja-fra","followers_url":"https://api.github.com/users/ja-fra/followers","following_url":"https://api.github.com/users/ja-fra/following{/other_user}","gists_url":"https://api.github.com/users/ja-fra/gists{/gist_id}","starred_url":"https://api.github.com/users/ja-fra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ja-fra/subscriptions","organizations_url":"https://api.github.com/users/ja-fra/orgs","repos_url":"https://api.github.com/users/ja-fra/repos","events_url":"https://api.github.com/users/ja-fra/events{/privacy}","received_events_url":"https://api.github.com/users/ja-fra/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T06:43:21Z","updated_at":"2016-10-12T06:43:21Z","body":"```\r\n> CONNECT www.google.com:443 HTTP/1.1\r\n> Host: www.google.com:443\r\n> Proxy-Connection: Keep-Alive\r\n> User-Agent: okhttp/3.4.1\r\n\r\n< HTTP/1.1 407 Proxy Authentication Required\r\n< Proxy-Authenticate: Basic realm=\"mitmproxy\"\r\n< \r\n< <html>\r\n<             <head>\r\n<                 <title>407 Proxy Authentication Required</title>\r\n<             </head>\r\n<             <body>Proxy Authentication Required</body>\r\n<         </html>\r\n\r\n> CONNECT www.google.com:443 HTTP/1.1\r\n> Host: www.goggle.com:443\r\n> Proxy-Connection: Keep-Alive\r\n> User-Agent: okhttp/2.7.5\r\n> Proxy-Authorization: Basic cHJveHl1c2VyOnByb3h5cGFzcw==\r\n```"}}
{"actor":{"display_login":"ja-fra"}}