2017-01-03 22:16:48 +01: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-15 00:25:21 +02:00
|
|
|
|
2018-12-21 19:17:15 +01:00
|
|
|
const httpAgent = require('_http_agent');
|
2017-10-07 16:50:42 +02: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-06 01:59:12 +01:00
|
|
|
let maxHeaderSize;
|
2011-07-26 00:15:15 +02:00
|
|
|
|
2018-03-20 00:14:46 +01:00
|
|
|
function createServer(opts, requestListener) {
|
|
|
|
return new Server(opts, requestListener);
|
2017-02-28 01:09:32 +01:00
|
|
|
}
|
2011-10-04 20:51:34 +02:00
|
|
|
|
2018-07-01 17:00:24 +02:00
|
|
|
function request(url, options, cb) {
|
|
|
|
return new ClientRequest(url, options, cb);
|
2017-02-28 01:09:32 +01:00
|
|
|
}
|
2011-02-05 00:14:58 +01:00
|
|
|
|
2018-07-01 17:00:24 +02:00
|
|
|
function get(url, options, cb) {
|
|
|
|
var req = request(url, options, cb);
|
2014-02-25 23:15:02 +01:00
|
|
|
req.end();
|
|
|
|
return req;
|
2017-02-28 01:09:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2018-03-20 15:54:58 +01:00
|
|
|
_connectionListener,
|
|
|
|
METHODS: methods.slice().sort(),
|
|
|
|
STATUS_CODES,
|
2018-12-21 19:17:15 +01:00
|
|
|
Agent: httpAgent.Agent,
|
2017-02-28 01:09:32 +01:00
|
|
|
ClientRequest,
|
2018-03-20 15:54:58 +01:00
|
|
|
IncomingMessage,
|
|
|
|
OutgoingMessage,
|
2017-02-28 01:09:32 +01:00
|
|
|
Server,
|
2018-03-20 15:54:58 +01:00
|
|
|
ServerResponse,
|
2017-02-28 01:09:32 +01:00
|
|
|
createServer,
|
|
|
|
get,
|
|
|
|
request
|
2011-10-04 20:51:34 +02:00
|
|
|
};
|
2018-12-06 01:59:12 +01: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 19:17:15 +01:00
|
|
|
|
|
|
|
Object.defineProperty(module.exports, 'globalAgent', {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: true,
|
|
|
|
get() {
|
|
|
|
return httpAgent.globalAgent;
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
httpAgent.globalAgent = value;
|
|
|
|
}
|
|
|
|
});
|