本文整理汇总了C#中Authenticator.CreateHttpWebRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Authenticator.CreateHttpWebRequest方法的具体用法?C# Authenticator.CreateHttpWebRequest怎么用?C# Authenticator.CreateHttpWebRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authenticator
的用法示例。
在下文中一共展示了Authenticator.CreateHttpWebRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareRequest
private HttpWebRequest PrepareRequest(Uri target,
Authenticator authentication,
string slug,
string contentType,
long contentLength,
string httpMethod) {
HttpWebRequest request = authentication.CreateHttpWebRequest(httpMethod, target);
request.Headers.Add(GDataRequestFactory.SlugHeader + ": " + slug);
request.Headers.Add(GDataRequestFactory.ContentOverrideHeader + ": " + contentType);
if (contentLength != -1) {
request.Headers.Add(GDataRequestFactory.ContentLengthOverrideHeader + ": " + contentLength);
}
return request;
}
示例2: QueryStatus
/// <summary>
/// askes the server about the current status
/// </summary>
/// <param name="authentication"></param>
/// <param name="targetUri"></param>
/// <returns></returns>
public static long QueryStatus(Authenticator authentication, Uri targetUri) {
HttpWebRequest request = authentication.CreateHttpWebRequest(HttpMethods.Post, targetUri);
long result = -1;
// add a range header
string contentRange = String.Format("bytes */*");
request.Headers.Add(HttpRequestHeader.ContentRange, contentRange);
request.ContentLength = 0;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
// now parse the header
string range = response.Headers["Range"];
string[] parts = range.Split('-');
if (parts.Length > 1 && parts[1] != null) {
result = long.Parse(parts[1]);
}
return result;
}
示例3: UploadStreamPart
private HttpWebResponse UploadStreamPart(int partIndex, string httpMethod, Uri sessionUri,
Authenticator authentication, Stream payload, string mediaType, AsyncData data) {
HttpWebRequest request = authentication.CreateHttpWebRequest(httpMethod, sessionUri);
request.AllowWriteStreamBuffering = false;
request.Timeout = 600000;
// write the data
request.ContentType = mediaType;
CopyData(payload, request, partIndex, data, sessionUri);
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
return response;
}
示例4: PrepareRequest
private HttpWebRequest PrepareRequest(Uri target,
Authenticator authentication,
string slug,
string contentType,
long contentLength,
string httpMethod) {
HttpWebRequest request = authentication.CreateHttpWebRequest(httpMethod, target);
request.Headers.Set(GDataRequestFactory.SlugHeader, Utilities.EncodeSlugHeader(slug));
request.Headers.Set(GDataRequestFactory.ContentOverrideHeader, contentType);
if (contentLength != -1) {
request.Headers.Set(GDataRequestFactory.ContentLengthOverrideHeader, contentLength.ToString());
}
return request;
}