{"action":"created","comment":{"url":"https://api.github.com/repos/square/okhttp/pulls/comments/23902617","id":23902617,"diff_hunk":"@@ -0,0 +1,132 @@\n+/*\n+ * Copyright (C) 2015 Square, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.squareup.okhttp.internal;\n+\n+import com.squareup.okhttp.ConnectionSpec;\n+\n+import java.io.IOException;\n+import java.io.InterruptedIOException;\n+import java.net.ProtocolException;\n+import java.net.SocketException;\n+import java.security.cert.CertificateException;\n+import java.util.Arrays;\n+import java.util.List;\n+import javax.net.ssl.SSLHandshakeException;\n+import javax.net.ssl.SSLProtocolException;\n+import javax.net.ssl.SSLSocket;\n+\n+/**\n+ * Handles the connection spec fallback strategy: When a secure socket connection fails\n+ * due to a handshake / protocol problem the connection may be retried with different protocols.\n+ * Instances are stateful and should be created and used for a single connection attempt.\n+ */\n+public class ConnectionSpecSelector {\n+\n+  private final List<ConnectionSpec> connectionSpecs;\n+  private int nextModeIndex;\n+  private boolean isFallbackPossible;\n+  private boolean isFallback;\n+\n+  public ConnectionSpecSelector(List<ConnectionSpec> connectionSpecs) {\n+    this.nextModeIndex = 0;\n+    this.connectionSpecs = connectionSpecs;\n+  }\n+\n+  /**\n+   * Configure the supplied {@link SSLSocket} to connect to the specified host using an appropriate\n+   * {@link ConnectionSpec}.\n+   *\n+   * @return the chosen {@link ConnectionSpec}","path":"okhttp/src/main/java/com/squareup/okhttp/internal/ConnectionSpecSelector.java","position":53,"original_position":53,"commit_id":"84c2da26019acffb8cf2171025173d08aaebb0d2","original_commit_id":"84c2da26019acffb8cf2171025173d08aaebb0d2","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"delete this line; I don't think it's useful","created_at":"2015-02-01T23:13:29Z","updated_at":"2015-02-01T23:13:29Z","html_url":"https://github.com/square/okhttp/pull/1339#discussion_r23902617","pull_request_url":"https://api.github.com/repos/square/okhttp/pulls/1339","_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments/23902617"},"html":{"href":"https://github.com/square/okhttp/pull/1339#discussion_r23902617"},"pull_request":{"href":"https://api.github.com/repos/square/okhttp/pulls/1339"}}},"pull_request":{"url":"https://api.github.com/repos/square/okhttp/pulls/1339","id":27627418,"html_url":"https://github.com/square/okhttp/pull/1339","diff_url":"https://github.com/square/okhttp/pull/1339.diff","patch_url":"https://github.com/square/okhttp/pull/1339.patch","issue_url":"https://api.github.com/repos/square/okhttp/issues/1339","number":1339,"state":"open","locked":false,"title":"Move TLS fallback into Connection + make TLS fallback try 3 times (but only if appropriate)","user":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"body":"Ready for a proper review.","created_at":"2015-01-19T18:42:23Z","updated_at":"2015-02-01T23:13:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ccc946bdfb719382a0f12f14aecc6587ade7cb42","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/okhttp/pulls/1339/commits","review_comments_url":"https://api.github.com/repos/square/okhttp/pulls/1339/comments","review_comment_url":"https://api.github.com/repos/square/okhttp/pulls/comments/{number}","comments_url":"https://api.github.com/repos/square/okhttp/issues/1339/comments","statuses_url":"https://api.github.com/repos/square/okhttp/statuses/84c2da26019acffb8cf2171025173d08aaebb0d2","head":{"label":"nfuller:AlternativeTlsFallback1","ref":"AlternativeTlsFallback1","sha":"84c2da26019acffb8cf2171025173d08aaebb0d2","user":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"repo":{"id":17255665,"name":"okhttp","full_name":"nfuller/okhttp","owner":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nfuller/okhttp","description":"An HTTP+SPDY client for Android and Java applications.","fork":true,"url":"https://api.github.com/repos/nfuller/okhttp","forks_url":"https://api.github.com/repos/nfuller/okhttp/forks","keys_url":"https://api.github.com/repos/nfuller/okhttp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nfuller/okhttp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nfuller/okhttp/teams","hooks_url":"https://api.github.com/repos/nfuller/okhttp/hooks","issue_events_url":"https://api.github.com/repos/nfuller/okhttp/issues/events{/number}","events_url":"https://api.github.com/repos/nfuller/okhttp/events","assignees_url":"https://api.github.com/repos/nfuller/okhttp/assignees{/user}","branches_url":"https://api.github.com/repos/nfuller/okhttp/branches{/branch}","tags_url":"https://api.github.com/repos/nfuller/okhttp/tags","blobs_url":"https://api.github.com/repos/nfuller/okhttp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nfuller/okhttp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nfuller/okhttp/git/refs{/sha}","trees_url":"https://api.github.com/repos/nfuller/okhttp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nfuller/okhttp/statuses/{sha}","languages_url":"https://api.github.com/repos/nfuller/okhttp/languages","stargazers_url":"https://api.github.com/repos/nfuller/okhttp/stargazers","contributors_url":"https://api.github.com/repos/nfuller/okhttp/contributors","subscribers_url":"https://api.github.com/repos/nfuller/okhttp/subscribers","subscription_url":"https://api.github.com/repos/nfuller/okhttp/subscription","commits_url":"https://api.github.com/repos/nfuller/okhttp/commits{/sha}","git_commits_url":"https://api.github.com/repos/nfuller/okhttp/git/commits{/sha}","comments_url":"https://api.github.com/repos/nfuller/okhttp/comments{/number}","issue_comment_url":"https://api.github.com/repos/nfuller/okhttp/issues/comments/{number}","contents_url":"https://api.github.com/repos/nfuller/okhttp/contents/{+path}","compare_url":"https://api.github.com/repos/nfuller/okhttp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nfuller/okhttp/merges","archive_url":"https://api.github.com/repos/nfuller/okhttp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nfuller/okhttp/downloads","issues_url":"https://api.github.com/repos/nfuller/okhttp/issues{/number}","pulls_url":"https://api.github.com/repos/nfuller/okhttp/pulls{/number}","milestones_url":"https://api.github.com/repos/nfuller/okhttp/milestones{/number}","notifications_url":"https://api.github.com/repos/nfuller/okhttp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nfuller/okhttp/labels{/name}","releases_url":"https://api.github.com/repos/nfuller/okhttp/releases{/id}","created_at":"2014-02-27T16:30:14Z","updated_at":"2014-11-08T03:10:19Z","pushed_at":"2015-01-26T09:51:05Z","git_url":"git://github.com/nfuller/okhttp.git","ssh_url":"git@github.com:nfuller/okhttp.git","clone_url":"https://github.com/nfuller/okhttp.git","svn_url":"https://github.com/nfuller/okhttp","homepage":"http://square.github.io/okhttp/","size":8172,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"621d270207adcfcf0560bb01c39a2915e0f557e8","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":5152285,"name":"okhttp","full_name":"square/okhttp","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/okhttp","description":"An HTTP+SPDY client for Android and Java applications.","fork":false,"url":"https://api.github.com/repos/square/okhttp","forks_url":"https://api.github.com/repos/square/okhttp/forks","keys_url":"https://api.github.com/repos/square/okhttp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/okhttp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/okhttp/teams","hooks_url":"https://api.github.com/repos/square/okhttp/hooks","issue_events_url":"https://api.github.com/repos/square/okhttp/issues/events{/number}","events_url":"https://api.github.com/repos/square/okhttp/events","assignees_url":"https://api.github.com/repos/square/okhttp/assignees{/user}","branches_url":"https://api.github.com/repos/square/okhttp/branches{/branch}","tags_url":"https://api.github.com/repos/square/okhttp/tags","blobs_url":"https://api.github.com/repos/square/okhttp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/okhttp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/okhttp/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/okhttp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/okhttp/statuses/{sha}","languages_url":"https://api.github.com/repos/square/okhttp/languages","stargazers_url":"https://api.github.com/repos/square/okhttp/stargazers","contributors_url":"https://api.github.com/repos/square/okhttp/contributors","subscribers_url":"https://api.github.com/repos/square/okhttp/subscribers","subscription_url":"https://api.github.com/repos/square/okhttp/subscription","commits_url":"https://api.github.com/repos/square/okhttp/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/okhttp/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/okhttp/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/okhttp/issues/comments/{number}","contents_url":"https://api.github.com/repos/square/okhttp/contents/{+path}","compare_url":"https://api.github.com/repos/square/okhttp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/okhttp/merges","archive_url":"https://api.github.com/repos/square/okhttp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/okhttp/downloads","issues_url":"https://api.github.com/repos/square/okhttp/issues{/number}","pulls_url":"https://api.github.com/repos/square/okhttp/pulls{/number}","milestones_url":"https://api.github.com/repos/square/okhttp/milestones{/number}","notifications_url":"https://api.github.com/repos/square/okhttp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/okhttp/labels{/name}","releases_url":"https://api.github.com/repos/square/okhttp/releases{/id}","created_at":"2012-07-23T13:42:55Z","updated_at":"2015-02-01T22:34:52Z","pushed_at":"2015-01-31T22:47:24Z","git_url":"git://github.com/square/okhttp.git","ssh_url":"git@github.com:square/okhttp.git","clone_url":"https://github.com/square/okhttp.git","svn_url":"https://github.com/square/okhttp","homepage":"http://square.github.io/okhttp/","size":25218,"stargazers_count":3302,"watchers_count":3302,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":734,"mirror_url":null,"open_issues_count":74,"forks":734,"open_issues":74,"watchers":3302,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/1339"},"html":{"href":"https://github.com/square/okhttp/pull/1339"},"issue":{"href":"https://api.github.com/repos/square/okhttp/issues/1339"},"comments":{"href":"https://api.github.com/repos/square/okhttp/issues/1339/comments"},"review_comments":{"href":"https://api.github.com/repos/square/okhttp/pulls/1339/comments"},"review_comment":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/square/okhttp/pulls/1339/commits"},"statuses":{"href":"https://api.github.com/repos/square/okhttp/statuses/84c2da26019acffb8cf2171025173d08aaebb0d2"}}}}