|
// This software code is made available "AS IS" without warranties of any
// kind. You may copy, display, modify and redistribute the software
// code either by itself or as incorporated into your code; provided that
// you do not remove any proprietary notices. Your use of this software
// code is at your own risk and you waive any claim against Amazon
// Digital Services, Inc. or its affiliates with respect to your use of
// this software code. (c) 2006 Amazon Digital Services, Inc. or its
// affiliates.
using System;
using System.Collections;
using System.Net;
using System.IO;
using System.Text;
namespace com.amazon.s3.rest
{
public class GetResponse : Response
{
private S3Object obj;
public S3Object Object {
get {
return obj;
}
}
public GetResponse( WebRequest request ) :
base(request)
{
SortedList metadata = extractMetadata( response );
string body = Utils.slurpInputStream( response.GetResponseStream() );
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(body);
this.obj = new S3Object( bytes, metadata);
}
private static SortedList extractMetadata( WebResponse response )
{
SortedList metadata = new SortedList();
foreach ( string key in response.Headers.Keys ) {
if ( key == null ) continue;
if ( key.StartsWith( Utils.METADATA_PREFIX ) ) {
metadata.Add( key.Substring( Utils.METADATA_PREFIX.Length ), response.Headers[ key ] );
}
}
return metadata;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.