Skip to content

Commit 36231a3

Browse files
committed
Support any method for Powershell
Taken from upstream
1 parent 48201c2 commit 36231a3

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/targets/powershell/common.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ const psSqEscape = function (input) {
1414
module.exports = function (command) {
1515
return function (source, options) {
1616
const code = new CodeBuilder()
17-
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
18-
19-
if (methods.indexOf(source.method.toUpperCase()) === -1) {
20-
return 'Method not supported'
21-
}
17+
const methods = [
18+
'DEFAULT',
19+
'DELETE',
20+
'GET',
21+
'HEAD',
22+
'MERGE',
23+
'OPTIONS',
24+
'PATCH',
25+
'POST',
26+
'PUT',
27+
'TRACE'
28+
]
29+
const methodArg = methods.includes(source.method.toUpperCase()) ? '-Method' : '-CustomMethod'
2230

2331
const commandOptions = []
2432

@@ -66,9 +74,10 @@ module.exports = function (command) {
6674
)
6775
}
6876

69-
code.push("$response = %s -Uri '%s' -Method %s %s",
77+
code.push("$response = %s -Uri '%s' %s %s %s",
7078
command,
7179
psSqEscape(source.fullUrl),
80+
methodArg,
7281
source.method,
7382
commandOptions.join(' ')
7483
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Method not supported
1+
$response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Method not supported
1+
$response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND

0 commit comments

Comments
 (0)