Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
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
3
Merge Requests
3
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
bs
node-bigstream
Commits
f9a03f93
Commit
f9a03f93
authored
Nov 18, 2019
by
Kamron Aroonrua
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do-http text post
parent
8753b1bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
perform.js
plugins/do/do-http/perform.js
+12
-4
No files found.
plugins/do/do-http/perform.js
View file @
f9a03f93
var
ctx
=
require
(
'../../../context'
);
var
Utils
=
ctx
.
getLib
(
'lib/util/plugin-utils'
);
var
bsdata
=
ctx
.
getLib
(
'lib/model/bsdata'
);
var
request
=
require
(
"request"
);
...
...
@@ -16,6 +15,7 @@ function perform_function(context,request,response){
var
req_url
=
param
.
url
||
""
;
var
req_method
=
param
.
method
||
"GET"
;
var
req_body_type
=
param
.
body_type
||
"json"
;
var
env
=
{
'type'
:
output_type
,
...
...
@@ -26,7 +26,7 @@ function perform_function(context,request,response){
var
req_url
=
Utils
.
vm_execute_text
(
env
,
req_url
);
send_request
({
'url'
:
req_url
,
'method'
:
req_method
,
'headers'
:
param
.
headers
,
'body'
:
data
},
function
(
err
){
send_request
({
'url'
:
req_url
,
'method'
:
req_method
,
'headers'
:
param
.
headers
,
'body
_type'
:
req_body_type
,
'body
'
:
data
},
function
(
err
){
if
(
!
err
){
response
.
success
();
}
else
{
...
...
@@ -50,8 +50,16 @@ function send_request(prm,cb)
if
(
prm
.
method
.
toLowerCase
()
==
'post'
||
prm
.
method
.
toLowerCase
()
==
'put'
)
{
options
.
method
=
prm
.
method
.
toUpperCase
();
if
(
body_type
==
'json'
&&
typeof
prm
.
body
==
'object'
){
options
.
headers
[
'content-type'
]
=
'application/json'
;
options
.
json
=
prm
.
body
;
}
else
if
(
body_type
==
'text'
||
typeof
prm
.
body
==
'string'
){
options
.
headers
[
'content-type'
]
=
'text/plain'
;
options
.
body
=
prm
.
body
;
}
else
{
options
.
body
=
prm
.
body
;
}
}
if
(
typeof
prm
.
headers
==
'object'
)
...
...
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