diff --git a/PushSharp.Google/GcmServiceConnection.cs b/PushSharp.Google/GcmServiceConnection.cs index b3b539c5..0308b950 100644 --- a/PushSharp.Google/GcmServiceConnection.cs +++ b/PushSharp.Google/GcmServiceConnection.cs @@ -53,14 +53,14 @@ public async Task Send (GcmNotification notification) { var json = notification.GetJson (); - var content = new StringContent (json, System.Text.Encoding.UTF8, "application/json"); - - var response = await http.PostAsync (Configuration.GcmUrl, content); - - if (response.IsSuccessStatusCode) { - await processResponseOk (response, notification).ConfigureAwait (false); - } else { - await processResponseError (response, notification).ConfigureAwait (false); + using (var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")) + using (var response = await http.PostAsync(Configuration.GcmUrl, content)) + { + if (response.IsSuccessStatusCode) { + await processResponseOk(response, notification).ConfigureAwait(false); + } else { + await processResponseError(response, notification).ConfigureAwait(false); + } } } @@ -212,5 +212,10 @@ static GcmResponseStatus GetGcmResponseStatus (string str) //Default return GcmResponseStatus.Error; } + + ~GcmServiceConnection() + { + http.Dispose(); + } } }