Sfoglia il codice sorgente

Merge pull request #8300 from Bond-009/dlnaregression

Claus Vium 2 anni fa
parent
commit
10484033f8
1 ha cambiato i file con 7 aggiunte e 4 eliminazioni
  1. 7 4
      Emby.Dlna/PlayTo/DlnaHttpClient.cs

+ 7 - 4
Emby.Dlna/PlayTo/DlnaHttpClient.cs

@@ -66,13 +66,15 @@ namespace Emby.Dlna.PlayTo
             }
             }
         }
         }
 
 
-        public Task<XDocument?> GetDataAsync(string url, CancellationToken cancellationToken)
+        public async Task<XDocument?> GetDataAsync(string url, CancellationToken cancellationToken)
         {
         {
             using var request = new HttpRequestMessage(HttpMethod.Get, url);
             using var request = new HttpRequestMessage(HttpMethod.Get, url);
-            return SendRequestAsync(request, cancellationToken);
+
+            // Have to await here instead of returning the Task directly, otherwise request would be disposed too soon
+            return await SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
         }
         }
 
 
-        public Task<XDocument?> SendCommandAsync(
+        public async Task<XDocument?> SendCommandAsync(
             string baseUrl,
             string baseUrl,
             DeviceService service,
             DeviceService service,
             string command,
             string command,
@@ -99,7 +101,8 @@ namespace Emby.Dlna.PlayTo
                 request.Headers.TryAddWithoutValidation("contentFeatures.dlna.org", header);
                 request.Headers.TryAddWithoutValidation("contentFeatures.dlna.org", header);
             }
             }
 
 
-            return SendRequestAsync(request, cancellationToken);
+            // Have to await here instead of returning the Task directly, otherwise request would be disposed too soon
+            return await SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
         }
         }
     }
     }
 }
 }