summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail/Transport/Web.cs
diff options
context:
space:
mode:
authorBrandon West <brawest@gmail.com>2015-04-21 17:11:14 -0600
committerBrandon West <brawest@gmail.com>2015-04-21 17:11:14 -0600
commit637193cd03ac89d6ce5f3894be47a7e940a6b59c (patch)
tree3d043ad5bd11064a0f352d8d7d2cbfe692689324 /SendGrid/SendGridMail/Transport/Web.cs
parent1e2b665d4358fc1c5e07da2a55adce311a8a58f0 (diff)
parent5b28a8a039946940fb6611e73d8dd78483435cb2 (diff)
downloadsendgrid-csharp-637193cd03ac89d6ce5f3894be47a7e940a6b59c.zip
sendgrid-csharp-637193cd03ac89d6ce5f3894be47a7e940a6b59c.tar.gz
sendgrid-csharp-637193cd03ac89d6ce5f3894be47a7e940a6b59c.tar.bz2
merge
Diffstat (limited to 'SendGrid/SendGridMail/Transport/Web.cs')
-rw-r--r--SendGrid/SendGridMail/Transport/Web.cs33
1 files changed, 15 insertions, 18 deletions
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs
index cd4bc9d..7c965f3 100644
--- a/SendGrid/SendGridMail/Transport/Web.cs
+++ b/SendGrid/SendGridMail/Transport/Web.cs
@@ -19,11 +19,10 @@ namespace SendGrid
#region Properties
//TODO: Make this configurable
- public const String BaseUrl = "api.sendgrid.com";
- public const String Endpoint = "/api/mail.send";
+ public const String Endpoint = "https://api.sendgrid.com/api/mail.send";
private readonly NetworkCredential _credentials;
- private readonly TimeSpan _timeout;
+ private readonly TimeSpan _timeout;
#endregion
@@ -37,16 +36,16 @@ namespace SendGrid
_timeout = TimeSpan.FromSeconds(100);
}
- /// <summary>
- /// Creates a new Web interface for sending mail.
- /// </summary>
- /// <param name="credentials">SendGridMessage user parameters</param>
- /// <param name="httpTimeout">HTTP request timeout</param>
- public Web(NetworkCredential credentials, TimeSpan httpTimeout)
- {
- _credentials = credentials;
- _timeout = httpTimeout;
- }
+ /// <summary>
+ /// Creates a new Web interface for sending mail.
+ /// </summary>
+ /// <param name="credentials">SendGridMessage user parameters</param>
+ /// <param name="httpTimeout">HTTP request timeout</param>
+ public Web(NetworkCredential credentials, TimeSpan httpTimeout)
+ {
+ _ credentials = credentials;
+ _ timeout = httpTimeout;
+ }
/// <summary>
/// Delivers a message over SendGrid's Web interface
@@ -54,8 +53,7 @@ namespace SendGrid
/// <param name="message"></param>
public void Deliver(ISendGrid message)
{
- var client = new HttpClient();
- client.Timeout = _timeout;
+ var client = new HttpClient()
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "sendgrid/" + version + ";csharp");
@@ -63,7 +61,7 @@ namespace SendGrid
var content = new MultipartFormDataContent();
AttachFormParams(message, content);
AttachFiles(message, content);
- var response = client.PostAsync("https://" + BaseUrl + Endpoint + ".xml", content).Result;
+ var response = client.PostAsync(Endpoint + ".xml", content).Result;
CheckForErrors(response);
}
@@ -73,8 +71,7 @@ namespace SendGrid
/// <param name="message"></param>
public async Task DeliverAsync(ISendGrid message)
{
- var client = new HttpClient();
- client.Timeout = _timeout;
+ var client = new HttpClient ();
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();