@@ -58,10 +58,9 @@ public async Task Send (GcmNotification notification)
5858 var response = await http . PostAsync ( Configuration . GcmUrl , content ) ;
5959
6060 if ( response . IsSuccessStatusCode ) {
61- await processResponseOk ( response , notification ) ;
61+ await processResponseOk ( response , notification ) . ConfigureAwait ( false ) ;
6262 } else {
63- var body = await response . Content . ReadAsStringAsync ( ) ;
64- processResponseError ( response , notification ) ;
63+ await processResponseError ( response , notification ) . ConfigureAwait ( false ) ;
6564 }
6665 }
6766
@@ -168,14 +167,20 @@ async Task processResponseOk (HttpResponseMessage httpResponse, GcmNotification
168167 throw multicastResult ;
169168 }
170169
171- void processResponseError ( HttpResponseMessage httpResponse , GcmNotification notification )
170+ async Task processResponseError ( HttpResponseMessage httpResponse , GcmNotification notification )
172171 {
172+ string responseBody = null ;
173+
174+ try {
175+ responseBody = await httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
176+ } catch { }
177+
173178 //401 bad auth token
174179 if ( httpResponse . StatusCode == HttpStatusCode . Unauthorized )
175180 throw new UnauthorizedAccessException ( "GCM Authorization Failed" ) ;
176181
177182 if ( httpResponse . StatusCode == HttpStatusCode . BadRequest )
178- throw new GcmConnectionException ( "HTTP 400 Bad Request" ) ;
183+ throw new GcmConnectionException ( "HTTP 400 Bad Request" , responseBody ) ;
179184
180185 if ( ( int ) httpResponse . StatusCode >= 500 && ( int ) httpResponse . StatusCode < 600 ) {
181186 //First try grabbing the retry-after header and parsing it.
@@ -187,7 +192,7 @@ void processResponseError (HttpResponseMessage httpResponse, GcmNotification not
187192 }
188193 }
189194
190- throw new GcmConnectionException ( "GCM HTTP Error: " + httpResponse . StatusCode ) ;
195+ throw new GcmConnectionException ( "GCM HTTP Error: " + httpResponse . StatusCode , responseBody ) ;
191196 }
192197
193198 static GcmResponseStatus GetGcmResponseStatus ( string str )
0 commit comments