Ejemplo n.º 1
0
        protected override WebRequest makeRequest(string method, string bucket, string key, SortedList <string, string> query, SortedList <string, string> headers, SortedList <string, string> metadata, Stream contentStream = null)
        {
            key = AwsConnection.encodeKeyForSignature(key);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(Utils.buildUrlBase(this.isSecure, this.server, this.port, bucket, this.callingFormat));
            if (key != null && key.Length != 0)
            {
                stringBuilder.Append(key);
            }
            stringBuilder.Append(Utils.convertQueryListToQueryString(query));
            WebRequest webRequest = WebRequest.Create(stringBuilder.ToString());

            if (webRequest is HttpWebRequest)
            {
                (webRequest as HttpWebRequest).AllowWriteStreamBuffering = false;
            }
            webRequest.Method = method;
            this.addHeaders(webRequest, headers);
            if (metadata != null)
            {
                this.addMetadataHeaders(webRequest, metadata);
            }
            this.addAuthHeader(webRequest, bucket, key, query);
            ConnectionBase.setRequestBody(contentStream, webRequest);
            return(webRequest);
        }
Ejemplo n.º 2
0
        public void addAuthHeader(WebRequest request, string bucket, string key, SortedList <string, string> query)
        {
            if (request.Headers["x-amz-date"] == null)
            {
                request.Headers.Add("x-amz-date", Utils.getHttpDate());
            }
            string str = Utils.encode(this.awsSecretAccessKey, AwsConnection.makeCanonicalString(bucket, key, query, request), false);

            request.Headers.Add("Authorization", "AWS " + this.awsAccessKeyId + ":" + str);
        }
Ejemplo n.º 3
0
        internal static string makeCanonicalString(string bucket, string key, SortedList <string, string> query, WebRequest request)
        {
            SortedList headers = new SortedList();

            foreach (string header in (NameObjectCollectionBase)request.Headers)
            {
                headers.Add((object)header, (object)request.Headers[header]);
            }
            if (headers[(object)"Content-Type"] == null)
            {
                headers.Add((object)"Content-Type", (object)request.ContentType);
            }
            return(AwsConnection.makeCanonicalString(request.Method, bucket, key, query, headers, (string)null));
        }
Ejemplo n.º 4
0
 internal static string makeCanonicalString(string bucket, string key, WebRequest request)
 {
     return(AwsConnection.makeCanonicalString(bucket, key, new SortedList <string, string>(), request));
 }