| Line | |
|---|
| 1 | package oauth.signpost.basic;
|
|---|
| 2 |
|
|---|
| 3 | import java.io.IOException;
|
|---|
| 4 | import java.io.InputStream;
|
|---|
| 5 | import java.net.HttpURLConnection;
|
|---|
| 6 |
|
|---|
| 7 | import oauth.signpost.http.HttpResponse;
|
|---|
| 8 |
|
|---|
| 9 | public class HttpURLConnectionResponseAdapter implements HttpResponse {
|
|---|
| 10 |
|
|---|
| 11 | private HttpURLConnection connection;
|
|---|
| 12 |
|
|---|
| 13 | public HttpURLConnectionResponseAdapter(HttpURLConnection connection) {
|
|---|
| 14 | this.connection = connection;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | public InputStream getContent() throws IOException {
|
|---|
| 18 | try {
|
|---|
| 19 | return connection.getInputStream();
|
|---|
| 20 | } catch (IOException e) {
|
|---|
| 21 | return connection.getErrorStream();
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | public int getStatusCode() throws IOException {
|
|---|
| 26 | return connection.getResponseCode();
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | public String getReasonPhrase() throws Exception {
|
|---|
| 30 | return connection.getResponseMessage();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | public Object unwrap() {
|
|---|
| 34 | return connection;
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.