Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

示例代码丢失严重,如:http模块的http.request(options, [callback])的示例代码 #20

Open
sandheart opened this issue Aug 21, 2014 · 0 comments

Comments

@sandheart
Copy link

URL:http://nodeapi.ucdok.com/api/http.html#http_http_request_options_callback_3163
中文版的只有:
// write data to request body
req.write('data\n');
req.write('data\n');
req.end();

英文版的为:
var options = {
hostname: 'www.google.com',
port: 80,
path: '/upload',
method: 'POST'
};

var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});

req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});

// write data to request body
req.write('data\n');
req.write('data\n');
req.end();

类似的情况在中文版API里还不少

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant