File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1132,12 +1132,20 @@ export class OpenAI {
11321132 return ( ) => controller . abort ( ) ;
11331133 }
11341134
1135- private buildBody ( { options : { body , headers : rawHeaders } } : { options : FinalRequestOptions } ) : {
1135+ private buildBody ( { options } : { options : FinalRequestOptions } ) : {
11361136 bodyHeaders : HeadersLike ;
11371137 body : BodyInit | undefined ;
11381138 isStreamingBody : boolean ;
11391139 } {
1140+ const { body, headers : rawHeaders } = options ;
11401141 if ( ! body ) {
1142+ // A resource method always passes a `body` key when its operation defines a
1143+ // request body, even if the caller omitted an optional body param. Keep the
1144+ // content-type for those, and only elide it for operations with no body at
1145+ // all (e.g. GET/DELETE).
1146+ if ( body == null && 'body' in options ) {
1147+ return this . #encoder( { body, headers : buildHeaders ( [ rawHeaders ] ) } ) ;
1148+ }
11411149 return { bodyHeaders : undefined , body : undefined , isStreamingBody : false } ;
11421150 }
11431151 const headers = buildHeaders ( [ rawHeaders ] ) ;
You can’t perform that action at this time.
0 commit comments