File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ use crate::{config::OPENAI_API_BASE, error::OpenAIError};
66
77#[ derive( Clone , Debug , Default ) ]
88pub struct RequestOptions {
9- query : Vec < ( String , String ) > ,
9+ query : Option < Vec < ( String , String ) > > ,
1010 headers : Option < HeaderMap > ,
1111}
1212
1313impl RequestOptions {
1414 pub ( crate ) fn new ( ) -> Self {
1515 Self {
16- query : Vec :: new ( ) ,
16+ query : None ,
1717 headers : None ,
1818 }
1919 }
@@ -66,15 +66,16 @@ impl RequestOptions {
6666 }
6767
6868 // Extract query pairs from the URL and append to our vec
69+ let query = self . query . get_or_insert_with ( Vec :: new) ;
6970 for ( key, value) in url. query_pairs ( ) {
70- self . query . push ( ( key. to_string ( ) , value. to_string ( ) ) ) ;
71+ query. push ( ( key. to_string ( ) , value. to_string ( ) ) ) ;
7172 }
7273
7374 Ok ( ( ) )
7475 }
7576
7677 pub ( crate ) fn query ( & self ) -> & [ ( String , String ) ] {
77- & self . query
78+ self . query . as_deref ( ) . unwrap_or ( & [ ] )
7879 }
7980
8081 pub ( crate ) fn headers ( & self ) -> Option < & HeaderMap > {
You can’t perform that action at this time.
0 commit comments