Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
3c357171
Unverified
Commit
3c357171
authored
Mar 14, 2024
by
Yeuoly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: http
parent
fcd470fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
5 deletions
+79
-5
entities.py
api/core/workflow/nodes/http_request/entities.py
+1
-1
http_executor.py
api/core/workflow/nodes/http_request/http_executor.py
+3
-3
http_request_node.py
api/core/workflow/nodes/http_request/http_request_node.py
+1
-1
test_http.py
api/tests/integration_tests/workflow/nodes/test_http.py
+74
-0
No files found.
api/core/workflow/nodes/http_request/entities.py
View file @
3c357171
...
@@ -33,7 +33,7 @@ class HttpRequestNodeData(BaseNodeData):
...
@@ -33,7 +33,7 @@ class HttpRequestNodeData(BaseNodeData):
return
v
return
v
class
Body
(
BaseModel
):
class
Body
(
BaseModel
):
type
:
Literal
[
None
,
'form-data'
,
'x-www-form-urlencoded'
,
'raw'
,
'json'
]
type
:
Literal
[
'none'
,
'form-data'
,
'x-www-form-urlencoded'
,
'raw'
,
'json'
]
data
:
Union
[
None
,
str
]
data
:
Union
[
None
,
str
]
variables
:
list
[
VariableSelector
]
variables
:
list
[
VariableSelector
]
...
...
api/core/workflow/nodes/http_request/http_executor.py
View file @
3c357171
...
@@ -131,8 +131,6 @@ class HttpExecutor:
...
@@ -131,8 +131,6 @@ class HttpExecutor:
self
.
headers
[
'Content-Type'
]
=
'application/json'
self
.
headers
[
'Content-Type'
]
=
'application/json'
elif
node_data
.
body
.
type
==
'x-www-form-urlencoded'
:
elif
node_data
.
body
.
type
==
'x-www-form-urlencoded'
:
self
.
headers
[
'Content-Type'
]
=
'application/x-www-form-urlencoded'
self
.
headers
[
'Content-Type'
]
=
'application/x-www-form-urlencoded'
# elif node_data.body.type == 'form-data':
# self.headers['Content-Type'] = 'multipart/form-data'
if
node_data
.
body
.
type
in
[
'form-data'
,
'x-www-form-urlencoded'
]:
if
node_data
.
body
.
type
in
[
'form-data'
,
'x-www-form-urlencoded'
]:
body
=
{}
body
=
{}
...
@@ -152,8 +150,10 @@ class HttpExecutor:
...
@@ -152,8 +150,10 @@ class HttpExecutor:
}
}
else
:
else
:
self
.
body
=
urlencode
(
body
)
self
.
body
=
urlencode
(
body
)
el
se
:
el
if
node_data
.
body
.
type
in
[
'json'
,
'raw'
]
:
self
.
body
=
original_body
self
.
body
=
original_body
elif
node_data
.
body
.
type
==
'none'
:
self
.
body
=
''
def
_assembling_headers
(
self
)
->
dict
[
str
,
Any
]:
def
_assembling_headers
(
self
)
->
dict
[
str
,
Any
]:
authorization
=
deepcopy
(
self
.
authorization
)
authorization
=
deepcopy
(
self
.
authorization
)
...
...
api/core/workflow/nodes/http_request/http_request_node.py
View file @
3c357171
...
@@ -42,7 +42,7 @@ class HttpRequestNode(BaseNode):
...
@@ -42,7 +42,7 @@ class HttpRequestNode(BaseNode):
inputs
=
variables
,
inputs
=
variables
,
outputs
=
{
outputs
=
{
'status_code'
:
response
.
status_code
,
'status_code'
:
response
.
status_code
,
'body'
:
response
,
'body'
:
response
.
body
,
'headers'
:
response
.
headers
'headers'
:
response
.
headers
},
},
process_data
=
{
process_data
=
{
...
...
api/tests/integration_tests/workflow/nodes/test_http.py
View file @
3c357171
...
@@ -84,6 +84,41 @@ def test_no_auth(setup_http_mock):
...
@@ -84,6 +84,41 @@ def test_no_auth(setup_http_mock):
assert
'?A=b'
in
data
assert
'?A=b'
in
data
assert
'X-Header: 123'
in
data
assert
'X-Header: 123'
in
data
@
pytest
.
mark
.
parametrize
(
'setup_http_mock'
,
[[
'none'
]],
indirect
=
True
)
def
test_custom_authorization_header
(
setup_http_mock
):
node
=
HttpRequestNode
(
config
=
{
'id'
:
'1'
,
'data'
:
{
'title'
:
'http'
,
'desc'
:
''
,
'variables'
:
[{
'variable'
:
'args1'
,
'value_selector'
:
[
'1'
,
'123'
,
'args1'
],
}],
'method'
:
'get'
,
'url'
:
'http://example.com'
,
'authorization'
:
{
'type'
:
'api-key'
,
'config'
:
{
'type'
:
'custom'
,
'api_key'
:
'Auth'
,
'header'
:
'X-Auth'
,
},
},
'headers'
:
'X-Header:123'
,
'params'
:
'A:b'
,
'body'
:
None
,
}
},
**
BASIC_NODE_DATA
)
result
=
node
.
run
(
pool
)
data
=
result
.
process_data
.
get
(
'request'
,
''
)
assert
'?A=b'
in
data
assert
'X-Header: 123'
in
data
assert
'X-Auth: Auth'
in
data
@
pytest
.
mark
.
parametrize
(
'setup_http_mock'
,
[[
'none'
]],
indirect
=
True
)
@
pytest
.
mark
.
parametrize
(
'setup_http_mock'
,
[[
'none'
]],
indirect
=
True
)
def
test_template
(
setup_http_mock
):
def
test_template
(
setup_http_mock
):
node
=
HttpRequestNode
(
config
=
{
node
=
HttpRequestNode
(
config
=
{
...
@@ -237,3 +272,42 @@ def test_form_data(setup_http_mock):
...
@@ -237,3 +272,42 @@ def test_form_data(setup_http_mock):
assert
'2'
in
data
assert
'2'
in
data
assert
'api-key: Basic ak-xxx'
in
data
assert
'api-key: Basic ak-xxx'
in
data
assert
'X-Header: 123'
in
data
assert
'X-Header: 123'
in
data
def
test_none_data
(
setup_http_mock
):
node
=
HttpRequestNode
(
config
=
{
'id'
:
'1'
,
'data'
:
{
'title'
:
'http'
,
'desc'
:
''
,
'variables'
:
[{
'variable'
:
'args1'
,
'value_selector'
:
[
'1'
,
'123'
,
'args1'
],
},
{
'variable'
:
'args2'
,
'value_selector'
:
[
'1'
,
'123'
,
'args2'
],
}],
'method'
:
'post'
,
'url'
:
'http://example.com'
,
'authorization'
:
{
'type'
:
'api-key'
,
'config'
:
{
'type'
:
'basic'
,
'api_key'
:
'ak-xxx'
,
'header'
:
'api-key'
,
}
},
'headers'
:
'X-Header:123'
,
'params'
:
'A:b'
,
'body'
:
{
'type'
:
'none'
,
'data'
:
'123123123'
},
}
},
**
BASIC_NODE_DATA
)
result
=
node
.
run
(
pool
)
data
=
result
.
process_data
.
get
(
'request'
,
''
)
assert
'api-key: Basic ak-xxx'
in
data
assert
'X-Header: 123'
in
data
assert
'123123123'
not
in
data
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment