Skip to content

Commit

Permalink
Merge pull request #61 from robocik/HttpResponseExceptionExtended
Browse files Browse the repository at this point in the history
Store all http headers from the response in HttpResponseException
  • Loading branch information
mosabua committed Mar 1, 2015
2 parents 1905fad + 6cb28ff commit f774c28
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
@@ -1,6 +1,7 @@
package org.ksoap2.transport;

import java.io.IOException;
import java.util.List;

/**
* HttpResponseException is an IOException that is to be thrown when a Http response code is different from 200.
Expand All @@ -11,6 +12,7 @@
public class HttpResponseException extends IOException {

private int statusCode;
private List responseHeaders;

public HttpResponseException(int statusCode) {
super();
Expand All @@ -22,6 +24,12 @@ public HttpResponseException(String detailMessage, int statusCode) {
this.statusCode = statusCode;
}

public HttpResponseException(String detailMessage, int statusCode,List responseHeaders) {
super(detailMessage);
this.statusCode = statusCode;
this.responseHeaders=responseHeaders;
}

public HttpResponseException(String message, Throwable cause, int statusCode) {
super(message, cause);
this.statusCode = statusCode;
Expand All @@ -40,4 +48,13 @@ public HttpResponseException(Throwable cause, int statusCode) {
public int getStatusCode() {
return statusCode;
}

/**
* Returns all http headers from this response
*
* @return response code
*/
public List getResponseHeaders() {
return responseHeaders;
}
}
Expand Up @@ -232,7 +232,7 @@ public List call(String soapAction, SoapEnvelope envelope, List headers, File ou
//first check the response code....
if (status != 200) {
//throw new IOException("HTTP request failed, HTTP status: " + status);
throw new HttpResponseException("HTTP request failed, HTTP status: " + status, status);
throw new HttpResponseException("HTTP request failed, HTTP status: " + status, status,retHeaders);
}

if (contentLength > 0) {
Expand Down

0 comments on commit f774c28

Please sign in to comment.