示例#1
0
 /// <summary>
 /// Creates a new FlurlResponse that wraps the give HttpResponseMessage.
 /// </summary>
 public FlurlResponse(HttpResponseMessage resp, CookieJar cookieJar = null)
 {
     ResponseMessage = resp;
     _headers        = new Lazy <IReadOnlyNameValueList <string> >(LoadHeaders);
     _cookies        = new Lazy <IReadOnlyList <FlurlCookie> >(LoadCookies);
     LoadCookieJar(cookieJar);
 }
示例#2
0
 private void LoadCookieJar(CookieJar jar)
 {
     if (jar == null)
     {
         return;
     }
     foreach (var cookie in Cookies)
     {
         jar.TryAddOrReplace(cookie, out _);                 // not added if cookie fails validation
     }
 }
示例#3
0
 /// <summary>
 /// Creates a new CookieJar and associates it with this request, which will be updated with any Set-Cookie
 /// headers present in the response and is suitable for reuse in subsequent requests.
 /// </summary>
 /// <param name="request">The IFlurlRequest.</param>
 /// <param name="cookieJar">The created CookieJar, which can be reused in subsequent requests.</param>
 /// <returns>This IFlurlClient instance.</returns>
 public static IFlurlRequest WithCookies(this IFlurlRequest request, out CookieJar cookieJar)
 {
     cookieJar = new CookieJar();
     return(request.WithCookies(cookieJar));
 }
示例#4
0
 /// <summary>
 /// Sets the CookieJar associated with this request, which will be updated with any Set-Cookie headers present
 /// in the response and is suitable for reuse in subsequent requests.
 /// </summary>
 /// <param name="request">The IFlurlRequest.</param>
 /// <param name="cookieJar">The CookieJar.</param>
 /// <returns>This IFlurlClient instance.</returns>
 public static IFlurlRequest WithCookies(this IFlurlRequest request, CookieJar cookieJar)
 {
     request.CookieJar = cookieJar;
     return(request);
 }