2017-01-03 13:16:48 -08:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2014-11-22 16:59:48 +01:00
|
|
|
'use strict';
|
2016-08-14 18:25:21 -04:00
|
|
|
|
2018-12-21 20:17:15 +02:00
|
|
|
const httpAgent = require('_http_agent');
|
2017-10-07 22:50:42 +08:00
|
|
|
const { ClientRequest } = require('_http_client');
|
2018-03-20 15:54:58 +01:00
|
|
|
const { methods } = require('_http_common');
|
|
|
|
const { IncomingMessage } = require('_http_incoming');
|
|
|
|
const { OutgoingMessage } = require('_http_outgoing');
|
|
|
|
const {
|
|
|
|
_connectionListener,
|
|
|
|
STATUS_CODES,
|
|
|
|
Server,
|
|
|
|
ServerResponse
|
|
|
|
} = require('_http_server');
|
2018-12-05 19:59:12 -05:00
|
|
|
let maxHeaderSize;
|
2011-07-26 00:15:15 +02:00
|
|
|
|
2018-03-19 16:14:46 -07:00
|
|
|
function createServer(opts, requestListener) {
|
|
|
|
return new Server(opts, requestListener);
|
2017-02-27 16:09:32 -08:00
|
|
|
}
|
2011-10-04 20:51:34 +02:00
|
|
|
|
2018-07-01 11:00:24 -04:00
|
|
|
function request(url, options, cb) {
|
|
|
|
return new ClientRequest(url, options, cb);
|
2017-02-27 16:09:32 -08:00
|
|
|
}
|
2011-02-04 15:14:58 -08:00
|
|
|
|
2018-07-01 11:00:24 -04:00
|
|
|
function get(url, options, cb) {
|
|
|
|
var req = request(url, options, cb);
|
2014-02-25 14:15:02 -08:00
|
|
|
req.end();
|
|
|
|
return req;
|
2017-02-27 16:09:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2018-03-20 15:54:58 +01:00
|
|
|
_connectionListener,
|
|
|
|
METHODS: methods.slice().sort(),
|
|
|
|
STATUS_CODES,
|
2018-12-21 20:17:15 +02:00
|
|
|
Agent: httpAgent.Agent,
|
2017-02-27 16:09:32 -08:00
|
|
|
ClientRequest,
|
2018-03-20 15:54:58 +01:00
|
|
|
IncomingMessage,
|
|
|
|
OutgoingMessage,
|
2017-02-27 16:09:32 -08:00
|
|
|
Server,
|
2018-03-20 15:54:58 +01:00
|
|
|
ServerResponse,
|
2017-02-27 16:09:32 -08:00
|
|
|
createServer,
|
|
|
|
get,
|
|
|
|
request
|
2011-10-04 20:51:34 +02:00
|
|
|
};
|
2018-12-05 19:59:12 -05:00
|
|
|
|
|
|
|
Object.defineProperty(module.exports, 'maxHeaderSize', {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: true,
|
|
|
|
get() {
|
|
|
|
if (maxHeaderSize === undefined) {
|
|
|
|
const { getOptionValue } = require('internal/options');
|
|
|
|
maxHeaderSize = getOptionValue('--max-http-header-size');
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxHeaderSize;
|
|
|
|
}
|
|
|
|
});
|
2018-12-21 20:17:15 +02:00
|
|
|
|
|
|
|
Object.defineProperty(module.exports, 'globalAgent', {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: true,
|
|
|
|
get() {
|
|
|
|
return httpAgent.globalAgent;
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
httpAgent.globalAgent = value;
|
|
|
|
}
|
|
|
|
});
|