HttpClientManager.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Common.Extensions;
  3. using MediaBrowser.Common.IO;
  4. using MediaBrowser.Common.Net;
  5. using MediaBrowser.Model.Logging;
  6. using MediaBrowser.Model.Net;
  7. using MediaBrowser.Model.Serialization;
  8. using System;
  9. using System.Collections.Concurrent;
  10. using System.Collections.Generic;
  11. using System.Globalization;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Net;
  15. using System.Net.Cache;
  16. using System.Net.Http;
  17. using System.Text;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. namespace MediaBrowser.Common.Implementations.HttpClientManager
  21. {
  22. /// <summary>
  23. /// Class HttpClientManager
  24. /// </summary>
  25. public class HttpClientManager : IHttpClient
  26. {
  27. /// <summary>
  28. /// The _logger
  29. /// </summary>
  30. private readonly ILogger _logger;
  31. /// <summary>
  32. /// The _app paths
  33. /// </summary>
  34. private readonly IApplicationPaths _appPaths;
  35. private readonly IJsonSerializer _jsonSerializer;
  36. //private readonly FileSystemRepository _cacheRepository;
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="HttpClientManager" /> class.
  39. /// </summary>
  40. /// <param name="appPaths">The kernel.</param>
  41. /// <param name="logger">The logger.</param>
  42. /// <param name="jsonSerializer">The json serializer.</param>
  43. /// <exception cref="System.ArgumentNullException">
  44. /// appPaths
  45. /// or
  46. /// logger
  47. /// </exception>
  48. public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IJsonSerializer jsonSerializer)
  49. {
  50. if (appPaths == null)
  51. {
  52. throw new ArgumentNullException("appPaths");
  53. }
  54. if (logger == null)
  55. {
  56. throw new ArgumentNullException("logger");
  57. }
  58. _logger = logger;
  59. _jsonSerializer = jsonSerializer;
  60. _appPaths = appPaths;
  61. //_cacheRepository = new FileSystemRepository(Path.Combine(_appPaths.CachePath, "http"));
  62. }
  63. /// <summary>
  64. /// Holds a dictionary of http clients by host. Use GetHttpClient(host) to retrieve or create a client for web requests.
  65. /// DON'T dispose it after use.
  66. /// </summary>
  67. /// <value>The HTTP clients.</value>
  68. private readonly ConcurrentDictionary<string, HttpClient> _httpClients = new ConcurrentDictionary<string, HttpClient>();
  69. /// <summary>
  70. /// Gets
  71. /// </summary>
  72. /// <param name="host">The host.</param>
  73. /// <returns>HttpClient.</returns>
  74. /// <exception cref="System.ArgumentNullException">host</exception>
  75. private HttpClient GetHttpClient(string host)
  76. {
  77. if (string.IsNullOrEmpty(host))
  78. {
  79. throw new ArgumentNullException("host");
  80. }
  81. HttpClient client;
  82. if (!_httpClients.TryGetValue(host, out client))
  83. {
  84. var handler = new WebRequestHandler
  85. {
  86. CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache),
  87. AutomaticDecompression = DecompressionMethods.None
  88. };
  89. client = new HttpClient(handler);
  90. client.Timeout = TimeSpan.FromSeconds(30);
  91. _httpClients.TryAdd(host, client);
  92. }
  93. return client;
  94. }
  95. /// <summary>
  96. /// Performs a GET request and returns the resulting stream
  97. /// </summary>
  98. /// <param name="options">The options.</param>
  99. /// <returns>Task{Stream}.</returns>
  100. /// <exception cref="HttpException"></exception>
  101. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  102. public async Task<Stream> Get(HttpRequestOptions options)
  103. {
  104. ValidateParams(options.Url, options.CancellationToken);
  105. //var urlHash = url.GetMD5().ToString();
  106. //var infoPath = _cacheRepository.GetResourcePath(urlHash + ".js");
  107. //var responsePath = _cacheRepository.GetResourcePath(urlHash + ".dat");
  108. //HttpResponseInfo cachedInfo = null;
  109. //try
  110. //{
  111. // cachedInfo = _jsonSerializer.DeserializeFromFile<HttpResponseInfo>(infoPath);
  112. //}
  113. //catch (FileNotFoundException)
  114. //{
  115. //}
  116. //if (cachedInfo != null && !cachedInfo.MustRevalidate && cachedInfo.Expires.HasValue && cachedInfo.Expires.Value > DateTime.UtcNow)
  117. //{
  118. // return GetCachedResponse(responsePath);
  119. //}
  120. options.CancellationToken.ThrowIfCancellationRequested();
  121. var message = GetHttpRequestMessage(options);
  122. //if (cachedInfo != null)
  123. //{
  124. // if (!string.IsNullOrEmpty(cachedInfo.Etag))
  125. // {
  126. // message.Headers.Add("If-None-Match", cachedInfo.Etag);
  127. // }
  128. // else if (cachedInfo.LastModified.HasValue)
  129. // {
  130. // message.Headers.IfModifiedSince = new DateTimeOffset(cachedInfo.LastModified.Value);
  131. // }
  132. //}
  133. if (options.ResourcePool != null)
  134. {
  135. await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false);
  136. }
  137. _logger.Info("HttpClientManager.Get url: {0}", options.Url);
  138. try
  139. {
  140. options.CancellationToken.ThrowIfCancellationRequested();
  141. var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false);
  142. EnsureSuccessStatusCode(response);
  143. options.CancellationToken.ThrowIfCancellationRequested();
  144. //cachedInfo = UpdateInfoCache(cachedInfo, url, infoPath, response);
  145. //if (response.StatusCode == HttpStatusCode.NotModified)
  146. //{
  147. // return GetCachedResponse(responsePath);
  148. //}
  149. //if (!string.IsNullOrEmpty(cachedInfo.Etag) || cachedInfo.LastModified.HasValue || (cachedInfo.Expires.HasValue && cachedInfo.Expires.Value > DateTime.UtcNow))
  150. //{
  151. // await UpdateResponseCache(response, responsePath).ConfigureAwait(false);
  152. // return GetCachedResponse(responsePath);
  153. //}
  154. return await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
  155. }
  156. catch (OperationCanceledException ex)
  157. {
  158. throw GetCancellationException(options.Url, options.CancellationToken, ex);
  159. }
  160. catch (HttpRequestException ex)
  161. {
  162. _logger.ErrorException("Error getting response from " + options.Url, ex);
  163. throw new HttpException(ex.Message, ex);
  164. }
  165. catch (Exception ex)
  166. {
  167. _logger.ErrorException("Error getting response from " + options.Url, ex);
  168. throw;
  169. }
  170. finally
  171. {
  172. if (options.ResourcePool != null)
  173. {
  174. options.ResourcePool.Release();
  175. }
  176. }
  177. }
  178. /// <summary>
  179. /// Performs a GET request and returns the resulting stream
  180. /// </summary>
  181. /// <param name="url">The URL.</param>
  182. /// <param name="resourcePool">The resource pool.</param>
  183. /// <param name="cancellationToken">The cancellation token.</param>
  184. /// <returns>Task{Stream}.</returns>
  185. public Task<Stream> Get(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
  186. {
  187. return Get(new HttpRequestOptions
  188. {
  189. Url = url,
  190. ResourcePool = resourcePool,
  191. CancellationToken = cancellationToken,
  192. });
  193. }
  194. /// <summary>
  195. /// Gets the specified URL.
  196. /// </summary>
  197. /// <param name="url">The URL.</param>
  198. /// <param name="cancellationToken">The cancellation token.</param>
  199. /// <returns>Task{Stream}.</returns>
  200. public Task<Stream> Get(string url, CancellationToken cancellationToken)
  201. {
  202. return Get(url, null, cancellationToken);
  203. }
  204. /// <summary>
  205. /// Gets the cached response.
  206. /// </summary>
  207. /// <param name="responsePath">The response path.</param>
  208. /// <returns>Stream.</returns>
  209. private Stream GetCachedResponse(string responsePath)
  210. {
  211. return File.OpenRead(responsePath);
  212. }
  213. /// <summary>
  214. /// Updates the cache.
  215. /// </summary>
  216. /// <param name="cachedInfo">The cached info.</param>
  217. /// <param name="url">The URL.</param>
  218. /// <param name="path">The path.</param>
  219. /// <param name="response">The response.</param>
  220. private HttpResponseInfo UpdateInfoCache(HttpResponseInfo cachedInfo, string url, string path, HttpResponseMessage response)
  221. {
  222. var fileExists = true;
  223. if (cachedInfo == null)
  224. {
  225. cachedInfo = new HttpResponseInfo();
  226. fileExists = false;
  227. }
  228. cachedInfo.Url = url;
  229. var etag = response.Headers.ETag;
  230. if (etag != null)
  231. {
  232. cachedInfo.Etag = etag.Tag;
  233. }
  234. var modified = response.Content.Headers.LastModified;
  235. if (modified.HasValue)
  236. {
  237. cachedInfo.LastModified = modified.Value.UtcDateTime;
  238. }
  239. else if (response.Headers.Age.HasValue)
  240. {
  241. cachedInfo.LastModified = DateTime.UtcNow.Subtract(response.Headers.Age.Value);
  242. }
  243. var expires = response.Content.Headers.Expires;
  244. if (expires.HasValue)
  245. {
  246. cachedInfo.Expires = expires.Value.UtcDateTime;
  247. }
  248. else
  249. {
  250. var cacheControl = response.Headers.CacheControl;
  251. if (cacheControl != null)
  252. {
  253. if (cacheControl.MaxAge.HasValue)
  254. {
  255. var baseline = cachedInfo.LastModified ?? DateTime.UtcNow;
  256. cachedInfo.Expires = baseline.Add(cacheControl.MaxAge.Value);
  257. }
  258. cachedInfo.MustRevalidate = cacheControl.MustRevalidate;
  259. }
  260. }
  261. if (string.IsNullOrEmpty(cachedInfo.Etag) && !cachedInfo.Expires.HasValue && !cachedInfo.LastModified.HasValue)
  262. {
  263. // Nothing to cache
  264. if (fileExists)
  265. {
  266. File.Delete(path);
  267. }
  268. }
  269. else
  270. {
  271. _jsonSerializer.SerializeToFile(cachedInfo, path);
  272. }
  273. return cachedInfo;
  274. }
  275. /// <summary>
  276. /// Updates the response cache.
  277. /// </summary>
  278. /// <param name="response">The response.</param>
  279. /// <param name="path">The path.</param>
  280. /// <returns>Task.</returns>
  281. private async Task UpdateResponseCache(HttpResponseMessage response, string path)
  282. {
  283. using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
  284. {
  285. using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
  286. {
  287. await stream.CopyToAsync(fs).ConfigureAwait(false);
  288. }
  289. }
  290. }
  291. /// <summary>
  292. /// Performs a POST request
  293. /// </summary>
  294. /// <param name="url">The URL.</param>
  295. /// <param name="postData">Params to add to the POST data.</param>
  296. /// <param name="resourcePool">The resource pool.</param>
  297. /// <param name="cancellationToken">The cancellation token.</param>
  298. /// <returns>stream on success, null on failure</returns>
  299. /// <exception cref="System.ArgumentNullException">postData</exception>
  300. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  301. public async Task<Stream> Post(string url, Dictionary<string, string> postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
  302. {
  303. ValidateParams(url, cancellationToken);
  304. if (postData == null)
  305. {
  306. throw new ArgumentNullException("postData");
  307. }
  308. cancellationToken.ThrowIfCancellationRequested();
  309. var strings = postData.Keys.Select(key => string.Format("{0}={1}", key, postData[key]));
  310. var postContent = string.Join("&", strings.ToArray());
  311. var content = new StringContent(postContent, Encoding.UTF8, "application/x-www-form-urlencoded");
  312. if (resourcePool != null)
  313. {
  314. await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
  315. }
  316. _logger.Info("HttpClientManager.Post url: {0}", url);
  317. try
  318. {
  319. cancellationToken.ThrowIfCancellationRequested();
  320. var msg = await GetHttpClient(GetHostFromUrl(url)).PostAsync(url, content, cancellationToken).ConfigureAwait(false);
  321. EnsureSuccessStatusCode(msg);
  322. return await msg.Content.ReadAsStreamAsync().ConfigureAwait(false);
  323. }
  324. catch (OperationCanceledException ex)
  325. {
  326. throw GetCancellationException(url, cancellationToken, ex);
  327. }
  328. catch (HttpRequestException ex)
  329. {
  330. _logger.ErrorException("Error getting response from " + url, ex);
  331. throw new HttpException(ex.Message, ex);
  332. }
  333. finally
  334. {
  335. if (resourcePool != null)
  336. {
  337. resourcePool.Release();
  338. }
  339. }
  340. }
  341. /// <summary>
  342. /// Downloads the contents of a given url into a temporary location
  343. /// </summary>
  344. /// <param name="options">The options.</param>
  345. /// <returns>Task{System.String}.</returns>
  346. /// <exception cref="System.ArgumentNullException">progress</exception>
  347. /// <exception cref="HttpException"></exception>
  348. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  349. public async Task<string> GetTempFile(HttpRequestOptions options)
  350. {
  351. ValidateParams(options.Url, options.CancellationToken);
  352. var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");
  353. if (options.Progress == null)
  354. {
  355. throw new ArgumentNullException("progress");
  356. }
  357. options.CancellationToken.ThrowIfCancellationRequested();
  358. if (options.ResourcePool != null)
  359. {
  360. await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false);
  361. }
  362. options.Progress.Report(0);
  363. _logger.Info("HttpClientManager.GetTempFile url: {0}, temp file: {1}", options.Url, tempFile);
  364. try
  365. {
  366. options.CancellationToken.ThrowIfCancellationRequested();
  367. using (var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(GetHttpRequestMessage(options), HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
  368. {
  369. EnsureSuccessStatusCode(response);
  370. options.CancellationToken.ThrowIfCancellationRequested();
  371. var contentLength = GetContentLength(response);
  372. if (!contentLength.HasValue)
  373. {
  374. // We're not able to track progress
  375. using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
  376. {
  377. using (var fs = new FileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
  378. {
  379. await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false);
  380. }
  381. }
  382. }
  383. else
  384. {
  385. using (var stream = ProgressStream.CreateReadProgressStream(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), options.Progress.Report, contentLength.Value))
  386. {
  387. using (var fs = new FileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
  388. {
  389. await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false);
  390. }
  391. }
  392. }
  393. options.Progress.Report(100);
  394. options.CancellationToken.ThrowIfCancellationRequested();
  395. }
  396. }
  397. catch (Exception ex)
  398. {
  399. HandleTempFileException(ex, options, tempFile);
  400. }
  401. finally
  402. {
  403. if (options.ResourcePool != null)
  404. {
  405. options.ResourcePool.Release();
  406. }
  407. }
  408. return tempFile;
  409. }
  410. /// <summary>
  411. /// Gets the message.
  412. /// </summary>
  413. /// <param name="options">The options.</param>
  414. /// <returns>HttpResponseMessage.</returns>
  415. private HttpRequestMessage GetHttpRequestMessage(HttpRequestOptions options)
  416. {
  417. var message = new HttpRequestMessage(HttpMethod.Get, options.Url);
  418. if (!string.IsNullOrEmpty(options.UserAgent))
  419. {
  420. message.Headers.Add("User-Agent", options.UserAgent);
  421. }
  422. if (!string.IsNullOrEmpty(options.AcceptHeader))
  423. {
  424. message.Headers.Add("Accept", options.AcceptHeader);
  425. }
  426. return message;
  427. }
  428. /// <summary>
  429. /// Gets the length of the content.
  430. /// </summary>
  431. /// <param name="response">The response.</param>
  432. /// <returns>System.Nullable{System.Int64}.</returns>
  433. private long? GetContentLength(HttpResponseMessage response)
  434. {
  435. IEnumerable<string> lengthValues;
  436. if (!response.Headers.TryGetValues("content-length", out lengthValues) && !response.Content.Headers.TryGetValues("content-length", out lengthValues))
  437. {
  438. return null;
  439. }
  440. return long.Parse(string.Join(string.Empty, lengthValues.ToArray()), UsCulture);
  441. }
  442. protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
  443. /// <summary>
  444. /// Handles the temp file exception.
  445. /// </summary>
  446. /// <param name="ex">The ex.</param>
  447. /// <param name="options">The options.</param>
  448. /// <param name="tempFile">The temp file.</param>
  449. /// <returns>Task.</returns>
  450. /// <exception cref="HttpException"></exception>
  451. private void HandleTempFileException(Exception ex, HttpRequestOptions options, string tempFile)
  452. {
  453. var operationCanceledException = ex as OperationCanceledException;
  454. if (operationCanceledException != null)
  455. {
  456. // Cleanup
  457. if (File.Exists(tempFile))
  458. {
  459. File.Delete(tempFile);
  460. }
  461. throw GetCancellationException(options.Url, options.CancellationToken, operationCanceledException);
  462. }
  463. _logger.ErrorException("Error getting response from " + options.Url, ex);
  464. var httpRequestException = ex as HttpRequestException;
  465. // Cleanup
  466. if (File.Exists(tempFile))
  467. {
  468. File.Delete(tempFile);
  469. }
  470. if (httpRequestException != null)
  471. {
  472. throw new HttpException(ex.Message, ex);
  473. }
  474. throw ex;
  475. }
  476. /// <summary>
  477. /// Validates the params.
  478. /// </summary>
  479. /// <param name="url">The URL.</param>
  480. /// <param name="cancellationToken">The cancellation token.</param>
  481. /// <exception cref="System.ArgumentNullException">url</exception>
  482. private void ValidateParams(string url, CancellationToken cancellationToken)
  483. {
  484. if (string.IsNullOrEmpty(url))
  485. {
  486. throw new ArgumentNullException("url");
  487. }
  488. if (cancellationToken == null)
  489. {
  490. throw new ArgumentNullException("cancellationToken");
  491. }
  492. }
  493. /// <summary>
  494. /// Gets the host from URL.
  495. /// </summary>
  496. /// <param name="url">The URL.</param>
  497. /// <returns>System.String.</returns>
  498. private string GetHostFromUrl(string url)
  499. {
  500. var start = url.IndexOf("://", StringComparison.OrdinalIgnoreCase) + 3;
  501. var len = url.IndexOf('/', start) - start;
  502. return url.Substring(start, len);
  503. }
  504. /// <summary>
  505. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  506. /// </summary>
  507. public void Dispose()
  508. {
  509. Dispose(true);
  510. GC.SuppressFinalize(this);
  511. }
  512. /// <summary>
  513. /// Releases unmanaged and - optionally - managed resources.
  514. /// </summary>
  515. /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
  516. protected virtual void Dispose(bool dispose)
  517. {
  518. if (dispose)
  519. {
  520. foreach (var client in _httpClients.Values.ToList())
  521. {
  522. client.Dispose();
  523. }
  524. _httpClients.Clear();
  525. }
  526. }
  527. /// <summary>
  528. /// Throws the cancellation exception.
  529. /// </summary>
  530. /// <param name="url">The URL.</param>
  531. /// <param name="cancellationToken">The cancellation token.</param>
  532. /// <param name="exception">The exception.</param>
  533. /// <returns>Exception.</returns>
  534. private Exception GetCancellationException(string url, CancellationToken cancellationToken, OperationCanceledException exception)
  535. {
  536. // If the HttpClient's timeout is reached, it will cancel the Task internally
  537. if (!cancellationToken.IsCancellationRequested)
  538. {
  539. var msg = string.Format("Connection to {0} timed out", url);
  540. _logger.Error(msg);
  541. // Throw an HttpException so that the caller doesn't think it was cancelled by user code
  542. return new HttpException(msg, exception) { IsTimedOut = true };
  543. }
  544. return exception;
  545. }
  546. /// <summary>
  547. /// Ensures the success status code.
  548. /// </summary>
  549. /// <param name="response">The response.</param>
  550. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  551. private void EnsureSuccessStatusCode(HttpResponseMessage response)
  552. {
  553. if (!response.IsSuccessStatusCode)
  554. {
  555. throw new HttpException(response.ReasonPhrase) { StatusCode = response.StatusCode };
  556. }
  557. }
  558. /// <summary>
  559. /// Posts the specified URL.
  560. /// </summary>
  561. /// <param name="url">The URL.</param>
  562. /// <param name="postData">The post data.</param>
  563. /// <param name="cancellationToken">The cancellation token.</param>
  564. /// <returns>Task{Stream}.</returns>
  565. public Task<Stream> Post(string url, Dictionary<string, string> postData, CancellationToken cancellationToken)
  566. {
  567. return Post(url, postData, null, cancellationToken);
  568. }
  569. }
  570. }