@@ -8,35 +8,19 @@ const getBuffer = require('./get-buffer-response')
88const HttpError = require ( './http-error' )
99
1010function request ( fetch , requestOptions ) {
11- // https://fetch.spec.whatwg.org/#methods
12- requestOptions . method = requestOptions . method . toUpperCase ( )
13-
14- // default content-type for JSON
15- if ( requestOptions . body && ! requestOptions . headers [ 'content-type' ] ) {
16- requestOptions . headers [ 'content-type' ] = 'application/json; charset=utf-8'
17- }
18-
19- // GitHub expects "content-length: 0" header for PUT/PATCH requests without body
20- // fetch does not allow to set `content-length` header, but we can set body to an empty string
21- if ( [ 'PATCH' , 'PUT' ] . indexOf ( requestOptions . method ) >= 0 && ! requestOptions . body ) {
22- requestOptions . body = ''
23- }
24-
2511 if ( isPlainObject ( requestOptions . body ) || Array . isArray ( requestOptions . body ) ) {
2612 requestOptions . body = JSON . stringify ( requestOptions . body )
2713 }
2814
2915 let headers = { }
3016 let status
3117
32- return fetch ( requestOptions . url , {
18+ return fetch ( requestOptions . url , Object . assign ( {
3319 method : requestOptions . method ,
3420 body : requestOptions . body ,
3521 headers : requestOptions . headers ,
36- redirect : requestOptions . redirect ,
37- timeout : requestOptions . timeout ,
38- agent : requestOptions . agent
39- } )
22+ redirect : requestOptions . redirect
23+ } , requestOptions . request ) )
4024
4125 . then ( response => {
4226 status = response . status
0 commit comments