protected override void ProcessResponse() { if (Reader.Name == "Error") { Error = S3Exception.FromErrorResponse(Reader, null); } else if (Reader.Name == "CopyObjectResult") { if (Reader.IsEmptyElement) { throw new Exception("Expected a non-empty <CopyObjectResult> element."); } Reader.ReadStartElement("CopyObjectResult"); this.LastModified = Reader.ReadElementContentAsDateTime("LastModified", ""); this.ETag = Reader.ReadElementContentAsString("ETag", ""); Reader.ReadEndElement(); } else { throw new Exception("Unknown S3 XML response tag: " + Reader.Name); } }
protected void TryThrowS3Exception(WebException exception) { // if this is a protocol error and the response type is XML, we can expect that // S3 sent us an <Error> message. if (exception.Status == WebExceptionStatus.ProtocolError && exception.Response.ContentType == "application/xml" && (exception.Response.ContentLength > 0 || exception.Response.Headers[HttpResponseHeader.TransferEncoding] == "chunked")) { var wrapped = S3Exception.FromWebException(exception); if (wrapped != null) { throw wrapped; // do this on a separate statement so the debugger can re-execute } } }