diff options
author | Barak Korren <[email protected]> | 2013-04-02 20:38:07 +0300 |
---|---|---|
committer | Barak Korren <[email protected]> | 2013-04-02 20:38:07 +0300 |
commit | 58a2577d48790c79adfd44bcfd662c980ce6cfe4 (patch) | |
tree | 523d814ea0b7b6f617fe515b186099c6e83fed72 /lib/dojo/request/node.js.uncompressed.js | |
parent | e470a273cf09562fb2f9c0c899002303f19c8d16 (diff) | |
parent | cc332603431102a682feda22b9cf0093a29f0176 (diff) |
Merge branch 'master' of https://github.com/gothfox/Tiny-Tiny-RSS.git
Diffstat (limited to 'lib/dojo/request/node.js.uncompressed.js')
-rw-r--r-- | lib/dojo/request/node.js.uncompressed.js | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/lib/dojo/request/node.js.uncompressed.js b/lib/dojo/request/node.js.uncompressed.js deleted file mode 100644 index 8c44b1988..000000000 --- a/lib/dojo/request/node.js.uncompressed.js +++ /dev/null @@ -1,191 +0,0 @@ -define("dojo/request/node", [ - 'require', - './util', - './handlers', - '../errors/RequestTimeoutError', - '../node!http', - '../node!https', - '../node!url', - '../node!stream'/*=====, - '../request', - '../_base/declare' =====*/ -], function(require, util, handlers, RequestTimeoutError, http, https, URL, stream/*=====, request, declare =====*/){ - var Stream = stream.Stream, - undefined; - - var defaultOptions = { - method: 'GET', - query: null, - data: undefined, - headers: {} - }; - function node(url, options){ - var response = util.parseArgs(url, util.deepCreate(defaultOptions, options), options && options.data instanceof Stream); - url = response.url; - options = response.options; - - var def = util.deferred( - response, - function(dfd, response){ - response.clientRequest.abort(); - } - ); - - url = URL.parse(url); - - var reqOptions = response.requestOptions = { - hostname: url.hostname, - port: url.port, - socketPath: options.socketPath, - method: options.method, - headers: options.headers, - agent: options.agent, - pfx: options.pfx, - key: options.key, - passphrase: options.passphrase, - cert: options.cert, - ca: options.ca, - ciphers: options.ciphers, - rejectUnauthorized: options.rejectUnauthorized === false ? false : true - }; - if(url.path){ - reqOptions.path = url.path; - } - if(options.user || options.password){ - reqOptions.auth = (options.user||'') + ':' + (options.password||''); - } - var req = response.clientRequest = (url.protocol === 'https:' ? https : http).request(reqOptions); - - if(options.socketOptions){ - if('timeout' in options.socketOptions){ - req.setTimeout(options.socketOptions.timeout); - } - if('noDelay' in options.socketOptions){ - req.setNoDelay(options.socketOptions.noDelay); - } - if('keepAlive' in options.socketOptions){ - var initialDelay = options.socketOptions.keepAlive; - req.setKeepAlive(initialDelay >= 0, initialDelay || 0); - } - } - - req.on('socket', function(){ - response.hasSocket = true; - def.progress(response); - }); - - req.on('response', function(clientResponse){ - response.clientResponse = clientResponse; - response.status = clientResponse.statusCode; - response.getHeader = function(headerName){ - return clientResponse.headers[headerName.toLowerCase()] || null; - }; - - var body = []; - clientResponse.on('data', function(chunk){ - body.push(chunk); - - // TODO: progress updates via the deferred - }); - clientResponse.on('end', function(){ - if(timeout){ - clearTimeout(timeout); - } - response.text = body.join(''); - handlers(response); - def.resolve(response); - }); - }); - - req.on('error', def.reject); - - if(options.data){ - if(typeof options.data === "string"){ - req.end(options.data); - }else{ - options.data.pipe(req); - } - }else{ - req.end(); - } - - if(options.timeout){ - var timeout = setTimeout(function(){ - def.cancel(new RequestTimeoutError(response)); - }, options.timeout); - } - - return def.promise; - } - - /*===== - node = function(url, options){ - // summary: - // Sends a request using the included http or https interface from node.js - // with the given URL and options. - // url: String - // URL to request - // options: dojo/request/node.__Options? - // Options for the request. - // returns: dojo/request.__Promise - }; - node.__BaseOptions = declare(request.__BaseOptions, { - // data: String|Object|Stream? - // Data to transfer. This is ignored for GET and DELETE - // requests. - // headers: Object? - // Headers to use for the request. - // user: String? - // Username to use during the request. - // password: String? - // Password to use during the request. - }); - node.__MethodOptions = declare(null, { - // method: String? - // The HTTP method to use to make the request. Must be - // uppercase. Default is `"GET"`. - }); - node.__Options = declare([node.__BaseOptions, node.__MethodOptions]); - - node.get = function(url, options){ - // summary: - // Send an HTTP GET request using XMLHttpRequest with the given URL and options. - // url: String - // URL to request - // options: dojo/request/node.__BaseOptions? - // Options for the request. - // returns: dojo/request.__Promise - }; - node.post = function(url, options){ - // summary: - // Send an HTTP POST request using XMLHttpRequest with the given URL and options. - // url: String - // URL to request - // options: dojo/request/node.__BaseOptions? - // Options for the request. - // returns: dojo/request.__Promise - }; - node.put = function(url, options){ - // summary: - // Send an HTTP PUT request using XMLHttpRequest with the given URL and options. - // url: String - // URL to request - // options: dojo/request/node.__BaseOptions? - // Options for the request. - // returns: dojo/request.__Promise - }; - node.del = function(url, options){ - // summary: - // Send an HTTP DELETE request using XMLHttpRequest with the given URL and options. - // url: String - // URL to request - // options: dojo/request/node.__BaseOptions? - // Options for the request. - // returns: dojo/request.__Promise - }; - =====*/ - - util.addCommonMethods(node); - - return node; -}); |