File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
## [ Unreleased]
8
8
### Breaking Change
9
9
### Fixed
10
+ - Fix ` curly.post ` and ` curly.head ` using wrong libcurl options to set the HTTP Method.
10
11
### Added
11
12
### Changed
12
13
Original file line number Diff line number Diff line change @@ -154,15 +154,36 @@ const create = (): CurlyFunction => {
154
154
155
155
curly . create = create
156
156
157
+ const httpMethodOptionsMap : Record <
158
+ string ,
159
+ null | ( ( m : string , o : CurlOptionValueType ) => CurlOptionValueType )
160
+ > = {
161
+ get : null ,
162
+ post : ( _m , o ) => ( {
163
+ post : true ,
164
+ ...o ,
165
+ } ) ,
166
+ head : ( _m , o ) => ( {
167
+ nobody : true ,
168
+ ...o ,
169
+ } ) ,
170
+ _ : ( m , o ) => ( {
171
+ customRequest : m ,
172
+ ...o ,
173
+ } ) ,
174
+ }
175
+
157
176
for ( const httpMethod of methods ) {
177
+ const httpMethodOptions =
178
+ httpMethodOptionsMap [ httpMethod ] || httpMethodOptionsMap [ '_' ]
179
+
158
180
// @ts -ignore
159
181
curly [ httpMethod ] =
160
- httpMethod === 'get'
182
+ httpMethodOptions === null
161
183
? curly
162
184
: ( url : string , options : CurlOptionValueType = { } ) =>
163
185
curly ( url , {
164
- customRequest : httpMethod ,
165
- ...options ,
186
+ ...httpMethodOptions ( httpMethod , options ) ,
166
187
} )
167
188
}
168
189
You can’t perform that action at this time.
0 commit comments