func.then(function (result) { var res={} res.header=result.headers; res.status=String(result.statusCode); res.second=(((new Date())-startDate)/1000).toFixed(3);
request.post(parm, (error, res, body) => { if(error){ }else{ console.log(res.statusCode); console.log(res.headers); fs.writeFile('bcdf.html', res.body) } });
//Write header it('can write headers', function(done) { const server = new StirFry(8080); server.req(function(req, res) { res.setHeader('content-type', 'text/html'); }); request('http://localhost:8080', function(error, response) { server.close(); if (error) done(error); response.headers['content-type'].should.equal('text/html'); done(); }); });
request(source) .on('response', function (resSource) { if (process.env.CONSOLELOG) console.log('Download ' + source.url + ': ' + resSource.statusCode + ' > ' + resSource.statusMessage); sourceStatusCode = resSource.statusCode; resSource.headers['content-type'] = undefined; // if the source response have this header, Dropbox may file for some types }) .pipe(request(destination) .on('response', function (resDestination) { if (process.env.CONSOLELOG) console.log('Upload ' + destination.url + ': ' + resDestination.statusCode + ' > ' + resDestination.statusMessage); MakeCallback(autodeskId, taskId, resDestination.statusCode, sourceStatusCode, data, callback); }));
request.get(remoteUrl) .on('response', function (response) { console.log('#ON:', response.statusCode, response.headers['content-type']); }) .on('err', function (err) { console.log('#ERR ', err); }) .pipe(writeStream) .on('end', function () { return result; });
function reqAndCheck (done, url, checkHeaders) { request({ uri: url }, function (err, response, body) { if (err) { return done(err); } var headers = response.headers; for (var key in checkHeaders) { assert.equal(headers[key], checkHeaders[key]); } assert.notEqual(body.length, 0); done(); }); }
request(options, function(error, response, body) { if (error || response.statusCode != 302) { callback('Unexpected response status code. Response code: ' + response.statusCode); return; } callback(null, response.headers.location); });
request.get(encodeURI(_url)) .on('response', function(response) { console.log(response.statusCode,response.headers['content-type']); }) .on('error',function(err){ res.json({ code: 500, data: JSON.parse(err) }); }) .on('end',function(){ console.log('request end'); }) .pipe(res);
request.post(param, (e, r, b)=> { console.log(r.headers); console.log(b); fs.writeFile('abc.html', b); })
request(options, function(error, response, body) { if (error || [301, 302].indexOf(response.statusCode) == -1) { callback('URL not recognized as supported'); return; } callback(null, response.headers.location); });
request(source) .on('response', function (resSource) { if (process.env.CONSOLELOG) console.log('Download ' + source.url + ': ' + resSource.statusCode + ' > ' + resSource.statusMessage); sourceStatusCode = resSource.statusCode; resSource.headers['content-type'] = undefined; // if the source response have this header, Dropbox may file for some types }) .pipe(request(destination) .on('response', function (resDestination) { if (process.env.CONSOLELOG) console.log('Upload ' + destination.url + ': ' + resDestination.statusCode + ' > ' + resDestination.statusMessage); MakeCallback(autodeskId, taskId, resDestination.statusCode, sourceStatusCode, data, callback); }));