internal async Task <DACPResponse> SubmitRequestAsync(DACPRequest request) { if (request.IncludeSessionID) { request.QueryParameters["session-id"] = SessionID.ToString(); } string uri = request.GetURI(); _log.Info("Submitting request for: " + uri); HttpResponseMessage response = await HttpClient.PostAsync(uri, request.HttpContent, request.CancellationToken).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { _log.Info("Invalid response ({0}) for: {1}", response.StatusCode, uri); throw new DACPRequestException(response); } byte[] data = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false); _log.Info("Received response for: " + uri); // Get the content of the first node IEnumerable <DACPNode> nodes = null; if (data.Length > 0) { data = DACPUtility.GetResponseNodes(data, true).First().Value; nodes = DACPUtility.GetResponseNodes(data); } return(new DACPResponse(response, nodes)); }
internal void HandleHTTPException(DACPRequest request, Exception e) { HandleHTTPException(request.GetURI(), e); }