
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Shortcut method similar to http.get() for HTTP POST requests with support for data and files
This utility extends the functionality of the 'http' library in stock node.js. It returns a post request function in a very similar way to node's http.get().
In the same style as http.get()
, this function calls req.end()
automatically
npm install http-post
http-post(options, data[, files[, callback]])
or
http-post(options, data[, callback])
Options are the same as the ones for http.request()
except method
will always be forced to POST
. Note that options
can be
replaced with the full URI of the request similar to http.get
allowing for
even greater flexiblity in your post requests.
Data should be key/value pairs of form data. This does not handle file data,
see the files
option below for more information on uploading files.
var data = {
name: "Sam",
email: "sam@emberlabs.org",
gender: "m",
languages: [
"C",
"C++",
"Java",
"JavaScript",
"PHP",
"Python"
]
}
Pass it an empty array if you do not need to send any form data.
This param is another JavaScript object that can contain many files to be posted
var files = [
{
param: "img",
path: "./assets/mycoolimage.png"
},
{
param: "somefile",
name: "mydata.txt",
path: "C:\\Users\\Sam\\Documents\\asdf.txt"
}
]
You may chose to specify an optional name
in your array. It will override the
file name as it exists in the filesystem and name it the name you specified for
the request.
Callback is the same from http.request(). It accepts an instance of http.ClientResponce that has been created during the time of the request.
Returns an instance of http.ClientRequest
Setting up
var http = require('http');
http.post = require('http-post');
Posting data
http.post('http://localhost/postscript.php', { name: 'Sam', email: 'sam@emberlabs.org' }, function(res){
response.setEncoding('utf8');
res.on('data', function(chunk) {
console.log(chunk);
});
});
Posting a file
var files = {
{
param: "file",
path: "./assets/img/something.png"
}
};
http.post('http://localhost/postscript.php', [], files, function(res){
//...
});
Posting multiple files
var files = {
{
param: "file",
path: "./assets/img/something.png"
},
{
param: "junk",
path: "/home/sam/hello.txt"
}
};
http.post('http://localhost/postscript.php', [], files, function(res){
// ...
});
Posting data and files
var data = {
name: 'Sam',
drink: 'coffee'
};
var files = {
{
param: "file",
path: "./assets/img/something.png"
},
{
param: "junk",
path: "/home/sam/hello.txt"
}
};
http.post('http://localhost/postscript.php', data, files, function(res){
// ...
});
FAQs
Shortcut method similar to http.get() for HTTP POST requests with support for data and files
The npm package http-post receives a total of 4,210 weekly downloads. As such, http-post popularity was classified as popular.
We found that http-post demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.