2 * Copyright (C) 2010 Prasanta Paul, http://prasanta-paul.blogspot.com
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package com.pras.conn;
\r
19 import com.pras.Log;
\r
22 * Wrapper class to hold Response from Server, Connection Exception etc.
\r
27 public class Response {
\r
29 String TAG = "HTTP_Response";
\r
31 boolean error = false;
\r
32 String responseCode;
\r
33 String responseMessage;
\r
34 String errorStreamMsg;
\r
36 Exception exception;
\r
39 public boolean isError() {
\r
42 public void setError(boolean error) {
\r
45 public String getResponseCode() {
\r
46 return responseCode;
\r
48 public void setResponseCode(String responseCode) {
\r
49 this.responseCode = responseCode;
\r
53 * 1xx: Informational
\r
60 if(this.responseCode.startsWith("2"))
\r
65 public String getResponseMessage() {
\r
66 return responseMessage;
\r
68 public void setResponseMessage(String responseMessage) {
\r
69 this.responseMessage = responseMessage;
\r
71 public String getErrorStreamMsg() {
\r
72 return errorStreamMsg;
\r
74 public void setErrorStreamMsg(String errorStreamMsg) {
\r
75 this.errorStreamMsg = errorStreamMsg;
\r
77 public String getOutput() {
\r
80 public void setOutput(String output) {
\r
81 this.output = output;
\r
83 public Exception getException() {
\r
86 public void setException(Exception exception) {
\r
87 this.exception = exception;
\r
90 public void printErrorLog(){
\r
91 Log.p(TAG, "HTTP Response Code: "+ getResponseCode());
\r
92 Log.p(TAG, "HTTP Response: "+ getResponseMessage());
\r
93 Log.p(TAG, "Error Msg from Server: "+ getErrorStreamMsg());
\r
94 if(exception != null){
\r
95 Log.p(TAG, "Error in Connection: "+ exception.getMessage());
\r
96 exception.printStackTrace();
\r