本文整理汇总了C#中HttpRequest.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest.ToString方法的具体用法?C# HttpRequest.ToString怎么用?C# HttpRequest.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Abort
public void Abort(HttpRequest request)
{
foreach (WebRequest state in RunningRequests) {
if (state.OriginalRequest == request) {
state.Aborted = true;
state.AbortRequest();
return;
}
}
Common.LogError("Unable to abort " + request.ToString() + ", probably not running anymore");
}
示例2: DoPost
// 执行Get
private static void DoPost(HttpRequest req)
{
Notifier.tempCodeDic.Clear();
if (req.IsFront)
{
// 网络日志
Logger.LogNet(LogType.Log, "发送:" + req.ToString());
HttpClient.Post(req, req.ToUrl(), req.ToData(), OnPostCallback);
}
else
{
HttpClient.Post(req, req.ToUrl(), req.ToData(), OnPostCallbackForBackstage);
}
}
示例3: SendRequest
/// <summary>
/// Sends the specified request using the connection's socket
/// </summary>
/// <param name="request"></param>
public virtual void SendRequest(
HttpRequest request,
HttpMessageProgressEventHandler onProgress,
object stateObject)
{
Debug.WriteLineIf(_verbose, "Sending request...", MY_TRACE_CATEGORY);
Debug.WriteIf(_verbose, request.ToString(false));
// lock the writer
lock(_messageWriter)
{
// send the message
_messageWriter.Write(_socket, null, request, onProgress, stateObject);
}
}
示例4: Request
public void Request(Uri uri)
{
Console.WriteLine("############################################################");
// request
var request = new HttpRequest(uri);
request.EnableEncoding();
request.SetKeepAlive(true);
Console.Write(request.ToString());
#if USE_BYTES_BODY
using (var subject = new ChunkedHttpResponseObserver())
{
var body = new Subject<IList<Byte>>();
body.Subscribe(x =>
{
Console.WriteLine("body: " + x.Count + " bytes");
}
, ex =>
{
Console.WriteLine(ex);
}
, () =>
{
Console.WriteLine("body end");
});
subject.BodyObservable.Subscribe(body);
bool keepAlive = true;
subject.KeepAliveObservalbe
.Subscribe(x =>
{
// disconnect
keepAlive = x;
});
#else
using (var subject = new HttpRawByteSubject())
{
var body = new Subject<Byte>();
var buffer = new List<Byte>();
body.Subscribe(x =>
{
buffer.Add(x);
}
, ex =>
{
Console.WriteLine(ex);
}
, () =>
{
Console.WriteLine("body: " + buffer.Count + " bytes");
Console.WriteLine("body end");
});
subject.BodyObservable.Subscribe(body);
#endif
// statusline
subject.StatusObservable.Subscribe(x =>
{
Console.WriteLine("status: " + x);
});
// response headers
subject.HeaderObservable.Subscribe(x =>
{
Console.WriteLine(x.Key + ": " + x.Value);
}
, () =>
{
Console.WriteLine();
}
);
////////////////////////////
// connect
////////////////////////////
GetConnection(uri)
.Subscribe(x =>
{
// ready to read
subject.OnNext(x);
// send request
x.SendRequestObservable(request)
.Subscribe(_ =>
{
});
}
, subject.OnError
)
;
// wait...
body.Wait();
if (!keepAlive)
{
Close();
}
//.........这里部分代码省略.........