Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Fixes http client buffer for large files, tempfile and timeout (#14)
Browse files Browse the repository at this point in the history
* only read headers into memory

* set infinite timeout for httpclient for soapRequests

* use unix slash for path

* remove superfluous tostring
  • Loading branch information
Jarle Pedersen authored Feb 25, 2019
1 parent 2a3d266 commit a4d7577
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CORESubscriber/Changelog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static XDocument SetTransactionValues(XElement transaction)

var xTransaction = new XDocument(transaction);

File.WriteAllText($"{Config.DownloadFolder}\\lastTransaction.xml", xTransaction.ToString());
File.WriteAllText($"{Config.DownloadFolder}/lastTransaction.xml", xTransaction.ToString());

return xTransaction;
}
Expand Down Expand Up @@ -168,7 +168,7 @@ private static string GetChangelogFileNameFromDownloadUrl(string downloadUrl)

private static HttpResponseMessage GetResult(string downloadUrl)
{
using (var client = SetCredentials(new HttpClient())) return client.GetAsync(downloadUrl).Result;
using (var client = SetCredentials(new HttpClient())) return client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).Result;
}

private static HttpClient SetCredentials(HttpClient client)
Expand Down
2 changes: 1 addition & 1 deletion CORESubscriber/SoapAction/GetChangelog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static string Run()

getChangelog.Descendants(Provider.GeosynchronizationNamespace + XmlAttributes.ChangelogId.LocalName).First()
.Value =
Dataset.OrderedChangelogId.ToString();
Dataset.OrderedChangelogId;

var responseContent = SoapRequest.Send(SoapActions.GetChangelog, getChangelog);

Expand Down
6 changes: 5 additions & 1 deletion CORESubscriber/SoapAction/SoapRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Xml.Linq;
using CORESubscriber.Xml;

Expand Down Expand Up @@ -37,7 +38,10 @@ private static HttpClient GetClient()
{
var byteArray = Encoding.ASCII.GetBytes(Provider.User + ":" + Provider.Password);

var client = new HttpClient();
var client = new HttpClient
{
Timeout = Timeout.InfiniteTimeSpan
};

client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
Expand Down

0 comments on commit a4d7577

Please sign in to comment.