예제 #1
0
		/// <summary>
		/// 验证响应。在这里抛出的异常将会导致请求被设置为失败。
		/// </summary>
		/// <param name="context"></param>
		public virtual void ValidateResponse(HttpContext context)
		{

		}
예제 #2
0
		/// <summary>
		/// 自定义处理Cookies
		/// </summary>
		/// <param name="context">当前的HTTP请求上下文</param>
		/// <param name="client">当前的客户端</param>
		/// <returns>如果返回 <see langword="false" />,那么客户端将会进行Cookies的默认处理。如果返回 <see langword="true" />,则表示Cookies已由第三方代码处理,类库本身不再处理</returns>
		public virtual bool ProcessCookies(HttpContext context, HttpClient client)
		{
			return false;
		}
예제 #3
0
		/// <summary>
		/// 获得比较最适合的用于处理响应的类型
		/// </summary>
		/// <typeparam name="T">当前希望获得的结果</typeparam>
		/// <param name="client">当前的HTTP客户端</param>
		/// <param name="ctx">当前的上下文环境</param>
		/// <param name="responseContent">当前用来处理结果的对象</param>
		/// <param name="streamInvoker">如果希望能按流处理,那么用来处理响应的事件委托</param>
		/// <param name="result">当前希望获得的结果实例</param>
		/// <param name="targetStream">要将相应内容写入的流</param>
		/// <param name="saveToFilePath">要将当前请求写入的文件路径</param>
		/// <returns></returns>
		public HttpResponseContent GetPreferedResponseType<T>(HttpClient client, HttpContext ctx, HttpResponseContent responseContent, EventHandler<ResponseStreamContent.RequireProcessStreamEventArgs> streamInvoker = null, T result = default(T), Stream targetStream = null, string saveToFilePath = null)
		{
			return responseContent;
		}
예제 #4
0
		/// <summary>
		/// 初始化上下文。此操作在上下文本身初始化完成之后、请求发出之前调用
		/// </summary>
		/// <param name="context"></param>
		public void PrepareContext(HttpContext context)
		{
		}
예제 #5
0
 internal void CopyDefaultSettings(HttpContext context)
 {
     context.WebRequest.CookieContainer = CookieContainer;
     Setting.CopyHeader(context.WebRequest);
 }
예제 #6
0
 /// <summary>
 /// 创建 <see cref="HttpResponseContent" />  的新实例(HttpResponseContent)
 /// </summary>
 internal ResponseFileContent(HttpContext context, HttpClient client, string filePath)
     : base(context, client)
 {
     FilePath = filePath;
 }