mirror of https://github.com/apache/jclouds.git
fixed azure blob error parsing when no content is returned
This commit is contained in:
parent
2f00ab22e4
commit
a0fbeb96e7
|
@ -68,13 +68,21 @@ public class ParseAzureStorageErrorFromXmlContent implements HttpErrorHandler {
|
||||||
try {
|
try {
|
||||||
if (response.getPayload() != null) {
|
if (response.getPayload() != null) {
|
||||||
String contentType = response.getPayload().getContentMetadata().getContentType();
|
String contentType = response.getPayload().getContentMetadata().getContentType();
|
||||||
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
|
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)
|
||||||
|
&& !new Long(0).equals(response.getPayload().getContentMetadata().getContentLength())) {
|
||||||
|
try {
|
||||||
AzureStorageError error = utils.parseAzureStorageErrorFromContent(command, response, response
|
AzureStorageError error = utils.parseAzureStorageErrorFromContent(command, response, response
|
||||||
.getPayload().getInput());
|
.getPayload().getInput());
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
message = error.getMessage();
|
message = error.getMessage();
|
||||||
exception = new AzureStorageResponseException(command, response, error);
|
exception = new AzureStorageResponseException(command, response, error);
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
try {
|
||||||
|
message = Utils.toStringAndClose(response.getPayload().getInput());
|
||||||
|
} catch (IOException e1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
message = Utils.toStringAndClose(response.getPayload().getInput());
|
message = Utils.toStringAndClose(response.getPayload().getInput());
|
||||||
|
|
|
@ -50,17 +50,28 @@ public class ParseAzureErrorFromXmlContentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test411WithTextHtmlIllegalArgumentException() {
|
public void test411WithTextHtmlIllegalArgumentException() {
|
||||||
assertCodeMakes("PUT", URI
|
assertCodeMakes("PUT",
|
||||||
.create("https://jclouds.blob.core.windows.net/adriancole-azureblob-413790770?restype=container"), 411,
|
URI.create("https://jclouds.blob.core.windows.net/adriancole-azureblob-413790770?restype=container"), 411,
|
||||||
"Length Required", "text/html; charset=us-ascii", "<HTML><HEAD><TITLE>Length Required</TITLE>\r\n",
|
"Length Required", "text/html; charset=us-ascii", "<HTML><HEAD><TITLE>Length Required</TITLE>\r\n",
|
||||||
IllegalArgumentException.class);
|
IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test304WithNoContentIllegalArgumentException() {
|
||||||
|
assertCodeMakes("GET", URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore0/apples"), 411,
|
||||||
|
"HTTP/1.1 304 The condition specified using HTTP conditional header(s) is not met.", "application/unknown",
|
||||||
|
"", IllegalArgumentException.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test412WithTextHtmlHttpResponseException() {
|
public void test412WithTextHtmlHttpResponseException() {
|
||||||
assertCodeMakes("GET", URI
|
assertCodeMakes(
|
||||||
.create("https://jclouds.blob.core.windows.net/adriancole-blobstore2?restype=container&comp=list&prefix=apps/apps/apps/&include=metadata"), 412,
|
"GET",
|
||||||
"HTTP/1.1 412 The condition specified using HTTP conditional header(s) is not met.", "application/xml", "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>ConditionNotMet</Code><Message>The condition specified using HTTP conditional header(s) is not met.\nRequestId:921efcad-84bc-4e0a-863d-24810d1096e1\nTime:2010-11-04T15:03:07.8694513Z</Message></Error>",
|
URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore2?restype=container&comp=list&prefix=apps/apps/apps/&include=metadata"),
|
||||||
|
412,
|
||||||
|
"HTTP/1.1 412 The condition specified using HTTP conditional header(s) is not met.",
|
||||||
|
"application/xml",
|
||||||
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>ConditionNotMet</Code><Message>The condition specified using HTTP conditional header(s) is not met.\nRequestId:921efcad-84bc-4e0a-863d-24810d1096e1\nTime:2010-11-04T15:03:07.8694513Z</Message></Error>",
|
||||||
AzureStorageResponseException.class);
|
AzureStorageResponseException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue