HttpClientManager.cs 25 KB

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