-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: update outdated links. (#976) Co-authored-by: richex <i@richex.cn> * feat: add new init params maxSockets * feat: add develop gitaction (#1017) * fix listV2 params error (#1011) * chore: develop merge master (#1035) sync master * chore(CI):github action optimized (#1040) * chore(test): test case optimized (#1041) * fix: fix list() and listV2() params and test case (#1043) * fix(test): test case optimized (#1044) * fix(test): test case optimized (#1045) * chore: use stream-http 2.8.2 * chore: rebuild * chore: rebuild * chore: document the completion Co-authored-by: richex-cn <hzxtiger@vip.qq.com> Co-authored-by: richex <i@richex.cn> Co-authored-by: peize.rpz <peize.rpz@alibaba-inc.com> Co-authored-by: taotao7 <moca_tao7@foxmail.com>
- Loading branch information
1 parent
17206a1
commit a759699
Showing
14 changed files
with
794 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
//"version": "2.8.2", | ||
var ClientRequest = require('./lib/request') | ||
var response = require('./lib/response') | ||
var extend = require('xtend') | ||
var statusCodes = require('builtin-status-codes') | ||
var url = require('url') | ||
|
||
var http = exports | ||
|
||
http.request = function (opts, cb) { | ||
if (typeof opts === 'string') | ||
opts = url.parse(opts) | ||
else | ||
opts = extend(opts) | ||
|
||
// Normally, the page is loaded from http or https, so not specifying a protocol | ||
// will result in a (valid) protocol-relative url. However, this won't work if | ||
// the protocol is something else, like 'file:' | ||
var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : '' | ||
|
||
var protocol = opts.protocol || defaultProtocol | ||
var host = opts.hostname || opts.host | ||
var port = opts.port | ||
var path = opts.path || '/' | ||
|
||
// Necessary for IPv6 addresses | ||
if (host && host.indexOf(':') !== -1) | ||
host = '[' + host + ']' | ||
|
||
// This may be a relative url. The browser should always be able to interpret it correctly. | ||
opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path | ||
opts.method = (opts.method || 'GET').toUpperCase() | ||
opts.headers = opts.headers || {} | ||
|
||
// Also valid opts.auth, opts.mode | ||
|
||
var req = new ClientRequest(opts) | ||
if (cb) | ||
req.on('response', cb) | ||
return req | ||
} | ||
|
||
http.get = function get (opts, cb) { | ||
var req = http.request(opts, cb) | ||
req.end() | ||
return req | ||
} | ||
|
||
http.ClientRequest = ClientRequest | ||
http.IncomingMessage = response.IncomingMessage | ||
|
||
http.Agent = function () {} | ||
http.Agent.defaultMaxSockets = 4 | ||
|
||
http.globalAgent = new http.Agent() | ||
|
||
http.STATUS_CODES = statusCodes | ||
|
||
http.METHODS = [ | ||
'CHECKOUT', | ||
'CONNECT', | ||
'COPY', | ||
'DELETE', | ||
'GET', | ||
'HEAD', | ||
'LOCK', | ||
'M-SEARCH', | ||
'MERGE', | ||
'MKACTIVITY', | ||
'MKCOL', | ||
'MOVE', | ||
'NOTIFY', | ||
'OPTIONS', | ||
'PATCH', | ||
'POST', | ||
'PROPFIND', | ||
'PROPPATCH', | ||
'PURGE', | ||
'PUT', | ||
'REPORT', | ||
'SEARCH', | ||
'SUBSCRIBE', | ||
'TRACE', | ||
'UNLOCK', | ||
'UNSUBSCRIBE' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) | ||
|
||
exports.writableStream = isFunction(global.WritableStream) | ||
|
||
exports.abortController = isFunction(global.AbortController) | ||
|
||
exports.blobConstructor = false | ||
try { | ||
new Blob([new ArrayBuffer(1)]) | ||
exports.blobConstructor = true | ||
} catch (e) {} | ||
|
||
// The xhr request to example.com may violate some restrictive CSP configurations, | ||
// so if we're running in a browser that supports `fetch`, avoid calling getXHR() | ||
// and assume support for certain features below. | ||
var xhr | ||
function getXHR () { | ||
// Cache the xhr value | ||
if (xhr !== undefined) return xhr | ||
|
||
if (global.XMLHttpRequest) { | ||
xhr = new global.XMLHttpRequest() | ||
// If XDomainRequest is available (ie only, where xhr might not work | ||
// cross domain), use the page location. Otherwise use example.com | ||
// Note: this doesn't actually make an http request. | ||
try { | ||
xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com') | ||
} catch(e) { | ||
xhr = null | ||
} | ||
} else { | ||
// Service workers don't have XHR | ||
xhr = null | ||
} | ||
return xhr | ||
} | ||
|
||
function checkTypeSupport (type) { | ||
var xhr = getXHR() | ||
if (!xhr) return false | ||
try { | ||
xhr.responseType = type | ||
return xhr.responseType === type | ||
} catch (e) {} | ||
return false | ||
} | ||
|
||
// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'. | ||
// Safari 7.1 appears to have fixed this bug. | ||
var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined' | ||
var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice) | ||
|
||
// If fetch is supported, then arraybuffer will be supported too. Skip calling | ||
// checkTypeSupport(), since that calls getXHR(). | ||
exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer')) | ||
|
||
// These next two tests unavoidably show warnings in Chrome. Since fetch will always | ||
// be used if it's available, just return false for these to avoid the warnings. | ||
exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream') | ||
exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && | ||
checkTypeSupport('moz-chunked-arraybuffer') | ||
|
||
// If fetch is supported, then overrideMimeType will be supported too. Skip calling | ||
// getXHR(). | ||
exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false) | ||
|
||
exports.vbArray = isFunction(global.VBArray) | ||
|
||
function isFunction (value) { | ||
return typeof value === 'function' | ||
} | ||
|
||
xhr = null // Help gc |
Oops, something went wrong.