public ServiceResponse Send(ServiceRequest request, ExecutionContext context) { SignRequest(request, context); var response = SendCore(request, context); HandleResponse(response, context.ResponseHandlers); return response; }
public void Sign(ServiceRequest request, ICredentials credentials) { var accessKeyId = credentials.AccessId; var secretAccessKey = credentials.AccessKey; var httpMethod = request.Method.ToString().ToUpperInvariant(); // Because the resource path to is different from the one in the request uri, // can't use ServiceRequest.ResourcePath here. var resourcePath = _resourcePath; if (!string.IsNullOrEmpty(secretAccessKey)) { var canonicalString = SignUtils.BuildCanonicalString(httpMethod, resourcePath, request); var signature = ServiceSignature.Create().ComputeSignature(secretAccessKey, canonicalString); request.Headers.Add(HttpHeaders.Authorization, "OSS " + accessKeyId + ":" + signature); } }
public ServiceResponse Send(ServiceRequest request, ExecutionContext context) { return(SendImpl(request, context, 0)); }
private ServiceRequest BuildRequest() { var conf = OssUtils.GetClientConfiguration(Client); var request = new ServiceRequest { Method = Method, Endpoint = OssUtils.MakeBucketEndpoint(Endpoint, Bucket, conf), ResourcePath = OssUtils.MakeResourcePath(Key) }; foreach(var p in Parameters) request.Parameters.Add(p.Key, p.Value); var adjustedTime = DateTime.UtcNow.AddSeconds(conf.TickOffset); request.Headers[HttpHeaders.Date] = DateUtils.FormatRfc822Date(adjustedTime); if (!Headers.ContainsKey(HttpHeaders.ContentType)) request.Headers[HttpHeaders.ContentType] = string.Empty; foreach(var h in Headers) request.Headers.Add(h.Key, h.Value); if (Context.Credentials.UseToken) request.Headers[HttpHeaders.SecurityToken] = Context.Credentials.SecurityToken; request.Content = Content; return request; }
protected abstract IAsyncResult BeginSendCore(ServiceRequest request, ExecutionContext context, AsyncCallback callback, Object state);
public IAsyncResult BeginSend(ServiceRequest request, ExecutionContext context, AsyncCallback callback, object state) { SignRequest(request, context); return BeginSendCore(request, context, callback, state); }
private static void SignRequest(ServiceRequest request, ExecutionContext context) { if (context.Signer != null) context.Signer.Sign(request, context.Credentials); }
protected abstract ServiceResponse SendCore(ServiceRequest request, ExecutionContext context);
public IAsyncResult BeginSend(ServiceRequest request, ExecutionContext context, AsyncCallback callback, object state) { SignRequest(request, context); return(BeginSendCore(request, context, callback, state)); }