LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 * Copyright (c) 2010 Google Inc. | 2 * Copyright (c) 2010 Google Inc. |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.apache.org/licenses/LICENSE-2.0 | 7 * http://www.apache.org/licenses/LICENSE-2.0 |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 OutputStream out = connection.getOutputStream(); | 79 OutputStream out = connection.getOutputStream(); |
80 try { | 80 try { |
81 content.writeTo(out); | 81 content.writeTo(out); |
82 } finally { | 82 } finally { |
83 out.close(); | 83 out.close(); |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 // connect | 87 // connect |
88 connection.connect(); | 88 boolean successfulConnection = false; |
89 return new NetHttpResponse(connection); | 89 try { |
| 90 connection.connect(); |
| 91 NetHttpResponse response = new NetHttpResponse(connection); |
| 92 successfulConnection = true; |
| 93 return response; |
| 94 } finally { |
| 95 if (!successfulConnection) { |
| 96 connection.disconnect(); |
| 97 } |
| 98 } |
90 } | 99 } |
91 | 100 |
92 @Override | 101 @Override |
93 public void setContent(HttpContent content) { | 102 public void setContent(HttpContent content) { |
94 this.content = content; | 103 this.content = content; |
95 } | 104 } |
96 } | 105 } |
LEFT | RIGHT |