@@ -188,30 +188,39 @@ impl ApiContext {
188188 /// Create a GET request with common headers (User-Agent, X-Distinct-ID)
189189 /// Use this for all HTTP GET requests to ensure consistent headers.
190190 /// The returned (Agent, Request) pair uses the system's native certificate store.
191- pub fn http_get ( url : & str , timeout_secs : Option < u64 > ) -> ( ureq:: Agent , ureq:: Request ) {
191+ pub fn http_get (
192+ url : & str ,
193+ timeout_secs : Option < u64 > ,
194+ ) -> (
195+ ureq:: Agent ,
196+ ureq:: RequestBuilder < ureq:: typestate:: WithoutBody > ,
197+ ) {
192198 let agent = http:: build_agent ( timeout_secs) ;
193199 let request = agent
194200 . get ( url)
195- . set (
201+ . header (
196202 "User-Agent" ,
197203 & format ! ( "git-ai/{}" , env!( "CARGO_PKG_VERSION" ) ) ,
198204 )
199- . set ( "X-Distinct-ID" , & config:: get_or_create_distinct_id ( ) ) ;
205+ . header ( "X-Distinct-ID" , & config:: get_or_create_distinct_id ( ) ) ;
200206 ( agent, request)
201207 }
202208
203209 /// Create a POST request with common headers (User-Agent, X-Distinct-ID)
204210 /// Use this for all HTTP POST requests to ensure consistent headers.
205211 /// The returned (Agent, Request) pair uses the system's native certificate store.
206- pub fn http_post ( url : & str , timeout_secs : Option < u64 > ) -> ( ureq:: Agent , ureq:: Request ) {
212+ pub fn http_post (
213+ url : & str ,
214+ timeout_secs : Option < u64 > ,
215+ ) -> ( ureq:: Agent , ureq:: RequestBuilder < ureq:: typestate:: WithBody > ) {
207216 let agent = http:: build_agent ( timeout_secs) ;
208217 let request = agent
209218 . post ( url)
210- . set (
219+ . header (
211220 "User-Agent" ,
212221 & format ! ( "git-ai/{}" , env!( "CARGO_PKG_VERSION" ) ) ,
213222 )
214- . set ( "X-Distinct-ID" , & config:: get_or_create_distinct_id ( ) ) ;
223+ . header ( "X-Distinct-ID" , & config:: get_or_create_distinct_id ( ) ) ;
215224 ( agent, request)
216225 }
217226
@@ -313,16 +322,16 @@ impl ApiContext {
313322 let body_json = serde_json:: to_string ( body) . map_err ( GitAiError :: JsonError ) ?;
314323
315324 let ( _agent, mut request) = Self :: http_post ( & url, self . timeout_secs ) ;
316- request = request. set ( "Content-Type" , "application/json" ) ;
325+ request = request. header ( "Content-Type" , "application/json" ) ;
317326
318327 if let Some ( api_key) = & self . api_key {
319- request = request. set ( "X-API-Key" , api_key) ;
328+ request = request. header ( "X-API-Key" , api_key) ;
320329 if let Some ( identity) = & self . author_identity {
321- request = request. set ( "X-Author-Identity" , identity) ;
330+ request = request. header ( "X-Author-Identity" , identity) ;
322331 }
323332 }
324333 if let Some ( token) = & self . auth_token {
325- request = request. set ( "Authorization" , & format ! ( "Bearer {}" , token) ) ;
334+ request = request. header ( "Authorization" , & format ! ( "Bearer {}" , token) ) ;
326335 }
327336
328337 http:: send_with_body ( request, & body_json)
@@ -336,13 +345,13 @@ impl ApiContext {
336345 let ( _agent, mut request) = Self :: http_get ( & url, self . timeout_secs ) ;
337346
338347 if let Some ( api_key) = & self . api_key {
339- request = request. set ( "X-API-Key" , api_key) ;
348+ request = request. header ( "X-API-Key" , api_key) ;
340349 if let Some ( identity) = & self . author_identity {
341- request = request. set ( "X-Author-Identity" , identity) ;
350+ request = request. header ( "X-Author-Identity" , identity) ;
342351 }
343352 }
344353 if let Some ( token) = & self . auth_token {
345- request = request. set ( "Authorization" , & format ! ( "Bearer {}" , token) ) ;
354+ request = request. header ( "Authorization" , & format ! ( "Bearer {}" , token) ) ;
346355 }
347356
348357 http:: send ( request) . map_err ( |e| GitAiError :: Generic ( format ! ( "HTTP request failed: {}" , e) ) )
0 commit comments