@@ -71,46 +71,46 @@ public virtual ElasticsearchResponse<Stream> DeleteSync(Uri uri, byte[] data, IR
7171
7272 private ElasticsearchResponse < Stream > HeaderOnlyRequest ( Uri uri , string method , IRequestConnectionConfiguration requestSpecificConfig )
7373 {
74- var r = this . CreateHttpWebRequest ( uri , method ) ;
74+ var r = this . CreateHttpWebRequest ( uri , method , requestSpecificConfig ) ;
7575 return this . DoSynchronousRequest ( r , requestSpecificConfig : requestSpecificConfig ) ;
7676 }
7777
7878 private ElasticsearchResponse < Stream > BodyRequest ( Uri uri , byte [ ] data , string method , IRequestConnectionConfiguration requestSpecificConfig )
7979 {
80- var r = this . CreateHttpWebRequest ( uri , method ) ;
80+ var r = this . CreateHttpWebRequest ( uri , method , requestSpecificConfig ) ;
8181 return this . DoSynchronousRequest ( r , data , requestSpecificConfig ) ;
8282 }
8383
8484 public virtual Task < ElasticsearchResponse < Stream > > Get ( Uri uri , IRequestConnectionConfiguration requestSpecificConfig = null )
8585 {
86- var r = this . CreateHttpWebRequest ( uri , "GET" ) ;
86+ var r = this . CreateHttpWebRequest ( uri , "GET" , requestSpecificConfig ) ;
8787 return this . DoAsyncRequest ( r , requestSpecificConfig : requestSpecificConfig ) ;
8888 }
8989 public virtual Task < ElasticsearchResponse < Stream > > Head ( Uri uri , IRequestConnectionConfiguration requestSpecificConfig = null )
9090 {
91- var r = this . CreateHttpWebRequest ( uri , "HEAD" ) ;
91+ var r = this . CreateHttpWebRequest ( uri , "HEAD" , requestSpecificConfig ) ;
9292 return this . DoAsyncRequest ( r , requestSpecificConfig : requestSpecificConfig ) ;
9393 }
9494 public virtual Task < ElasticsearchResponse < Stream > > Post ( Uri uri , byte [ ] data , IRequestConnectionConfiguration requestSpecificConfig = null )
9595 {
96- var r = this . CreateHttpWebRequest ( uri , "POST" ) ;
96+ var r = this . CreateHttpWebRequest ( uri , "POST" , requestSpecificConfig ) ;
9797 return this . DoAsyncRequest ( r , data , requestSpecificConfig : requestSpecificConfig ) ;
9898 }
9999
100100 public virtual Task < ElasticsearchResponse < Stream > > Put ( Uri uri , byte [ ] data , IRequestConnectionConfiguration requestSpecificConfig = null )
101101 {
102- var r = this . CreateHttpWebRequest ( uri , "PUT" ) ;
102+ var r = this . CreateHttpWebRequest ( uri , "PUT" , requestSpecificConfig ) ;
103103 return this . DoAsyncRequest ( r , data , requestSpecificConfig : requestSpecificConfig ) ;
104104 }
105105
106106 public virtual Task < ElasticsearchResponse < Stream > > Delete ( Uri uri , byte [ ] data , IRequestConnectionConfiguration requestSpecificConfig = null )
107107 {
108- var r = this . CreateHttpWebRequest ( uri , "DELETE" ) ;
108+ var r = this . CreateHttpWebRequest ( uri , "DELETE" , requestSpecificConfig ) ;
109109 return this . DoAsyncRequest ( r , data , requestSpecificConfig : requestSpecificConfig ) ;
110110 }
111111 public virtual Task < ElasticsearchResponse < Stream > > Delete ( Uri uri , IRequestConnectionConfiguration requestSpecificConfig = null )
112112 {
113- var r = this . CreateHttpWebRequest ( uri , "DELETE" ) ;
113+ var r = this . CreateHttpWebRequest ( uri , "DELETE" , requestSpecificConfig ) ;
114114 return this . DoAsyncRequest ( r , requestSpecificConfig : requestSpecificConfig ) ;
115115 }
116116
@@ -127,9 +127,9 @@ private static void ThreadTimeoutCallback(object state, bool timedOut)
127127 }
128128
129129
130- protected virtual HttpWebRequest CreateHttpWebRequest ( Uri uri , string method )
130+ protected virtual HttpWebRequest CreateHttpWebRequest ( Uri uri , string method , IRequestConnectionConfiguration requestSpecificConfig )
131131 {
132- var myReq = this . CreateWebRequest ( uri , method ) ;
132+ var myReq = this . CreateWebRequest ( uri , method , requestSpecificConfig ) ;
133133 this . SetBasicAuthorizationIfNeeded ( myReq ) ;
134134 this . SetProxyIfNeeded ( myReq ) ;
135135 return myReq ;
@@ -160,17 +160,19 @@ private void SetBasicAuthorizationIfNeeded(HttpWebRequest myReq)
160160 //}
161161 }
162162
163- protected virtual HttpWebRequest CreateWebRequest ( Uri uri , string method )
163+ protected virtual HttpWebRequest CreateWebRequest ( Uri uri , string method , IRequestConnectionConfiguration requestSpecificConfig )
164164 {
165165 //TODO append global querystring
166166 //var url = this._CreateUriString(path);
167167
168168 var myReq = ( HttpWebRequest ) WebRequest . Create ( uri ) ;
169- //TODO move this to transport
170- if ( ! uri . AbsolutePath . StartsWith ( "_cat" ) )
169+
170+ myReq . Accept = "application/json" ;
171+ myReq . ContentType = "application/json" ;
172+ if ( requestSpecificConfig != null && ! string . IsNullOrWhiteSpace ( requestSpecificConfig . AcceptsContentType ) )
171173 {
172- myReq . Accept = "application/json" ;
173- myReq . ContentType = "application/json" ;
174+ myReq . Accept = requestSpecificConfig . AcceptsContentType ;
175+ myReq . ContentType = requestSpecificConfig . AcceptsContentType ;
174176 }
175177 var timeout = this . _ConnectionSettings . Timeout ;
176178 myReq . Timeout = timeout ; // 1 minute timeout.
0 commit comments