Skip to content

Commit 2ebff7a

Browse files
Jiakaicparambharat
authored andcommitted
fix: set method to POST when body exists (langgenius#14523) (langgenius#14524)
1 parent 5d6b01c commit 2ebff7a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

web/app/components/workflow/nodes/http/components/curl-panel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
2222
const node: Partial<HttpNodeType> = {
2323
title: 'HTTP Request',
2424
desc: 'Imported from cURL',
25-
method: Method.get,
25+
method: undefined,
2626
url: '',
2727
headers: '',
2828
params: '',
2929
body: { type: BodyType.none, data: '' },
3030
}
3131
const args = curlCommand.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || []
32+
let hasData = false
3233

3334
for (let i = 1; i < args.length; i++) {
3435
const arg = args[i].replace(/^['"]|['"]$/g, '')
@@ -38,6 +39,7 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
3839
if (i + 1 >= args.length)
3940
return { node: null, error: 'Missing HTTP method after -X or --request.' }
4041
node.method = (args[++i].replace(/^['"]|['"]$/g, '') as Method) || Method.get
42+
hasData = true
4143
break
4244
case '-H':
4345
case '--header':
@@ -89,6 +91,9 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str
8991
}
9092
}
9193

94+
// Determine final method
95+
node.method = node.method || (hasData ? Method.post : Method.get)
96+
9297
if (!node.url)
9398
return { node: null, error: 'Missing URL or url not start with http.' }
9499

0 commit comments

Comments
 (0)