@@ -301,9 +301,9 @@ protected virtual void Dispose(bool disposing)
301301 /// <para>-or-</para>
302302 /// <para>If <paramref name="parameters"/> is <see langword="null"/>.</para>
303303 /// </exception>
304- public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , CancellationToken cancellationToken , Func < Uri , Uri > uriTransform , string mediaType = "application/json" )
304+ public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , CancellationToken cancellationToken , Func < Uri , Uri > uriTransform )
305305 {
306- var prepared = PrepareRequestAsyncFunc ( method , template , parameters , cancellationToken , mediaType ) ;
306+ var prepared = PrepareRequestAsyncFunc ( method , template , parameters , cancellationToken ) ;
307307 if ( uriTransform == null )
308308 return prepared ;
309309
@@ -343,7 +343,7 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T>(Http
343343 /// <para>-or-</para>
344344 /// <para>If <paramref name="parameters"/> is <see langword="null"/>.</para>
345345 /// </exception>
346- public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , CancellationToken cancellationToken , string mediaType = "application/json" )
346+ public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , CancellationToken cancellationToken )
347347 {
348348 if ( template == null )
349349 throw new ArgumentNullException ( "template" ) ;
@@ -354,7 +354,7 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T>(Http
354354 task =>
355355 {
356356 Uri baseUri = task . Result ;
357- HttpRequestMessage request = PrepareRequestImpl ( method , template , baseUri , parameters , mediaType ) ;
357+ HttpRequestMessage request = PrepareRequestImpl ( method , template , baseUri , parameters ) ;
358358
359359 Func < Task < HttpRequestMessage > , Task < HttpRequestMessage > > authenticateRequest =
360360 task2 => AuthenticationService . AuthenticateRequestAsync ( task2 . Result , cancellationToken ) . Select ( _ => task2 . Result ) ;
@@ -393,7 +393,7 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T>(Http
393393 /// <para>-or-</para>
394394 /// <para>If <paramref name="parameters"/> is <see langword="null"/>.</para>
395395 /// </exception>
396- public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T , TBody > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , TBody body , CancellationToken cancellationToken , Func < Uri , Uri > uriTransform , string mediaType = "application/json" )
396+ public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T , TBody > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , TBody body , CancellationToken cancellationToken , Func < Uri , Uri > uriTransform )
397397 {
398398 var prepared = PrepareRequestAsyncFunc ( method , template , parameters , body , cancellationToken ) ;
399399 if ( uriTransform == null )
@@ -439,7 +439,7 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T, TBod
439439 /// <para>-or-</para>
440440 /// <para>If <paramref name="parameters"/> is <see langword="null"/>.</para>
441441 /// </exception>
442- public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T , TBody > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , TBody body , CancellationToken cancellationToken , string mediaType = "application/json" )
442+ public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T , TBody > ( HttpMethod method , UriTemplate template , IDictionary < string , T > parameters , TBody body , CancellationToken cancellationToken )
443443 {
444444 return
445445 task =>
@@ -454,20 +454,6 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T, TBod
454454 } ;
455455 }
456456
457- public Func < Task < Uri > , Task < HttpRequestMessage > > PrepareRequestAsyncFunc < T , TBody > ( HttpMethod method , string mediaType , UriTemplate template , IDictionary < string , T > parameters , TBody body , CancellationToken cancellationToken )
458- {
459- return
460- task =>
461- {
462- Uri baseUri = task . Result ;
463- HttpRequestMessage request = PrepareRequestImpl ( method , template , baseUri , parameters ) ;
464- request . Content = EncodeRequestBodyImpl ( request , body , mediaType ) ;
465-
466- Func < Task < HttpRequestMessage > , Task < HttpRequestMessage > > authenticateRequest =
467- task2 => AuthenticationService . AuthenticateRequestAsync ( task2 . Result , cancellationToken ) . Select ( _ => task2 . Result ) ;
468- return CompletedTask . FromResult ( request ) . Then ( authenticateRequest ) ;
469- } ;
470- }
471457 /// <summary>
472458 /// Encode the body of a request, and update the <see cref="HttpRequestMessage"/> properties as necessary to
473459 /// support the encoded body.
@@ -485,15 +471,15 @@ public Func<Task<Uri>, Task<HttpRequestMessage>> PrepareRequestAsyncFunc<T, TBod
485471 /// <returns>An <see cref="HttpContent"/> object representing the body of the
486472 /// <see cref="HttpRequestMessage"/>.</returns>
487473 /// <exception cref="ArgumentNullException">If <paramref name="request"/> is <see langword="null"/>.</exception>
488- protected virtual HttpContent EncodeRequestBodyImpl < TBody > ( HttpRequestMessage request , TBody body , string mediaType = "application/json" )
474+ protected virtual HttpContent EncodeRequestBodyImpl < TBody > ( HttpRequestMessage request , TBody body )
489475 {
490476 if ( request == null )
491477 throw new ArgumentNullException ( "request" ) ;
492478
493479 string bodyText = JsonConvert . SerializeObject ( body ) ;
494480 byte [ ] encodedBody = Encoding . UTF8 . GetBytes ( bodyText ) ;
495481 ByteArrayContent content = new ByteArrayContent ( encodedBody ) ;
496- content . Headers . ContentType = new MediaTypeHeaderValue ( mediaType ) { CharSet = "UTF-8" } ;
482+ content . Headers . ContentType = new MediaTypeHeaderValue ( "application/json" ) { CharSet = "UTF-8" } ;
497483
498484 content . Headers . ContentLength = encodedBody . Length ;
499485
@@ -547,12 +533,12 @@ protected virtual HttpContent EncodeRequestBodyImpl<TBody>(HttpRequestMessage re
547533 /// <para>If <paramref name="parameters"/> is <see langword="null"/>.</para>
548534 /// </exception>
549535 /// <exception cref="ArgumentException">If <paramref name="baseUri"/> is not an absolute URI.</exception>
550- protected virtual HttpRequestMessage PrepareRequestImpl < T > ( HttpMethod method , UriTemplate template , Uri baseUri , IDictionary < string , T > parameters , string mediaType = "application/json" )
536+ protected virtual HttpRequestMessage PrepareRequestImpl < T > ( HttpMethod method , UriTemplate template , Uri baseUri , IDictionary < string , T > parameters )
551537 {
552538 Uri boundUri = template . BindByName ( baseUri , parameters ) ;
553539
554540 HttpRequestMessage request = new HttpRequestMessage ( method , boundUri ) ;
555- request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( mediaType ) ) ;
541+ request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
556542 request . Headers . UserAgent . Add ( new ProductInfoHeaderValue ( AssemblyInfo . AssemblyProduct , AssemblyInfo . AssemblyInformationalVersion ) ) ;
557543#if ! PORTABLE
558544 if ( ConnectionLimit . HasValue )
0 commit comments