{"version":3,"sources":["webpack:///./node_modules/superagent/lib/client.js","webpack:///./node_modules/superagent/lib/is-object.js","webpack:///./node_modules/superagent/lib/request-base.js","webpack:///./node_modules/superagent/lib/request.js"],"names":["root","window","self","console","warn","this","Emitter","requestBase","isObject","noop","request","module","exports","bind","Request","getXHR","XMLHttpRequest","location","protocol","ActiveXObject","e","Error","trim","s","replace","serialize","obj","pairs","key","pushEncodedKeyValuePair","join","val","Array","isArray","forEach","v","subkey","push","encodeURIComponent","parseString","str","pair","pos","split","i","len","length","indexOf","decodeURIComponent","slice","isJSON","mime","test","Response","req","options","xhr","text","method","responseType","responseText","statusText","_setStatusProperties","status","header","headers","parseHeader","index","line","field","lines","fields","pop","toLowerCase","getAllResponseHeaders","getResponseHeader","_setHeaderProperties","body","_parseBody","response","url","_query","_header","on","new_err","err","res","parse","original","rawResponse","statusCode","callback","emit","serializeObject","types","html","json","xml","urlencoded","JSON","stringify","prototype","get","ct","type","shift","params","reduce","parts","Object","statusType","info","ok","clientError","serverError","error","toError","accepted","noContent","badRequest","unauthorized","notAcceptable","notFound","forbidden","msg","del","fn","end","set","_responseType","accept","auth","user","pass","btoa","username","password","query","attach","file","filename","_getFormData","append","name","_formData","FormData","_callback","clearTimeout","crossDomainError","crossDomain","_timeoutError","timeout","_timeout","_appendQueryString","data","_data","onreadystatechange","readyState","timedout","_aborted","handleProgress","direction","total","percent","loaded","hasListeners","onprogress","upload","_timer","setTimeout","abort","open","_withCredentials","withCredentials","_isHost","contentType","_serializer","setRequestHeader","send","head","patch","post","put","_clearTimeout","_parser","ms","then","resolve","reject","_fullfilledPromise","Promise","innerResolve","innerReject","catch","cb","undefined","use","getHeader","unset","redirects","n","_maxRedirects","toJSON","toString","call","RequestConstructor","arguments"],"mappings":"+EAIA,IAAIA,EACkB,oBAAXC,OACTD,EAAOC,OACkB,oBAATC,KAChBF,EAAOE,MAEPC,QAAQC,KAAK,uEACbJ,EAAOK,MAGT,IAAIC,EAAU,EAAQ,KAClBC,EAAc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,IAGzB,IAAK,gBACL,IAAK,gBACL,IAAK,oBACH,OAAO,EACT,QACE,OAAO,IA4Cbd,EAAQsK,KAAO,SAASxB,GACtB,IAAIhI,EAAMlB,EAASkJ,GACflD,EAAOnG,KAAK6E,QAAQ,gBAGxB,GAAIxD,GAAOlB,EAASH,KAAKsJ,OACvB,IAAK,IAAI/H,KAAO8H,EACdrJ,KAAKsJ,MAAM/H,GAAO8H,EAAK9H,OAEhB,iBAAmB8H,GAEvBlD,GAAMnG,KAAKmG,KAAK,QACrBA,EAAOnG,KAAK6E,QAAQ,gBAElB7E,KAAKsJ,MADH,qCAAuCnD,EAC5BnG,KAAKsJ,MACdtJ,KAAKsJ,MAAQ,IAAMD,EACnBA,GAEUrJ,KAAKsJ,OAAS,IAAMD,GAGpCrJ,KAAKsJ,MAAQD,EAGf,OAAKhI,GAAOrB,KAAKyK,QAAQpB,IAGpBlD,GAAMnG,KAAKmG,KAAK,QAHkBnG,O,kBC/UzCM,EAAOC,QAdP,SAASF,QAAQmM,EAAoBnJ,EAAQsB,GAE3C,MAAI,mBAAqBA,EAChB,IAAI6H,EAAmB,MAAOnJ,GAAQqE,IAAI/C,GAI/C,GAAK8H,UAAUhK,OACV,IAAI+J,EAAmB,MAAOnJ,GAGhC,IAAImJ,EAAmBnJ,EAAQsB","file":"npm.superagent-6fdb71edd2a0ab3535b8.js","sourcesContent":["/**\n * Root reference for iframes.\n */\n\nvar root;\nif (typeof window !== 'undefined') { // Browser window\n root = window;\n} else if (typeof self !== 'undefined') { // Web Worker\n root = self;\n} else { // Other environments\n console.warn(\"Using browser-only version of superagent in non-browser environment\");\n root = this;\n}\n\nvar Emitter = require('emitter');\nvar requestBase = require('./request-base');\nvar isObject = require('./is-object');\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Expose `request`.\n */\n\nvar request = module.exports = require('./request').bind(null, Request);\n\n/**\n * Determine XHR.\n */\n\nrequest.getXHR = function () {\n if (root.XMLHttpRequest\n && (!root.location || 'file:' != root.location.protocol\n || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n throw Error(\"Browser-only verison of superagent could not find XHR\");\n};\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n pushEncodedKeyValuePair(pairs, key, obj[key]);\n }\n return pairs.join('&');\n}\n\n/**\n * Helps 'serialize' with serializing arrays.\n * Mutates the pairs array.\n *\n * @param {Array} pairs\n * @param {String} key\n * @param {Mixed} val\n */\n\nfunction pushEncodedKeyValuePair(pairs, key, val) {\n if (val != null) {\n if (Array.isArray(val)) {\n val.forEach(function(v) {\n pushEncodedKeyValuePair(pairs, key, v);\n });\n } else if (isObject(val)) {\n for(var subkey in val) {\n pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);\n }\n } else {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(val));\n }\n } else if (val === null) {\n pairs.push(encodeURIComponent(key));\n }\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var pair;\n var pos;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n pos = pair.indexOf('=');\n if (pos == -1) {\n obj[decodeURIComponent(pair)] = '';\n } else {\n obj[decodeURIComponent(pair.slice(0, pos))] =\n decodeURIComponent(pair.slice(pos + 1));\n }\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Check if `mime` is json or has +json structured syntax suffix.\n *\n * @param {String} mime\n * @return {Boolean}\n * @api private\n */\n\nfunction isJSON(mime) {\n return /[\\/+]json\\b/.test(mime);\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return str.split(/ *; */).reduce(function(obj, str){\n var parts = str.split(/ *= */),\n key = parts.shift(),\n val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n // responseText is accessible only if responseType is '' or 'text' and on older browsers\n this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')\n ? this.xhr.responseText\n : null;\n this.statusText = this.req.xhr.statusText;\n this._setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this._setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this._parseBody(this.text ? this.text : this.xhr.response)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype._setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype._parseBody = function(str){\n var parse = request.parse[this.type];\n if (!parse && isJSON(this.type)) {\n parse = request.parse['application/json'];\n }\n return parse && str && (str.length || str instanceof Object)\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype._setStatusProperties = function(status){\n // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n if (status === 1223) {\n status = 204;\n }\n\n var type = status / 100 | 0;\n\n // status / class\n this.status = this.statusCode = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {}; // preserves header name case\n this._header = {}; // coerces header names to lowercase\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self);\n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n // issue #675: return the raw response if the response parsing fails\n err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;\n // issue #876: return the http status code if the response parsing fails\n err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;\n return self.callback(err);\n }\n\n self.emit('response', res);\n\n var new_err;\n try {\n if (res.status < 200 || res.status >= 300) {\n new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n new_err.original = err;\n new_err.response = res;\n new_err.status = res.status;\n }\n } catch(e) {\n new_err = e; // #985 touching res may cause INVALID_STATE_ERR on old Android\n }\n\n // #1000 don't catch errors from the callback to avoid double calling it\n if (new_err) {\n self.callback(new_err, res);\n } else {\n self.callback(null, res);\n }\n });\n}\n\n/**\n * Mixin `Emitter` and `requestBase`.\n */\n\nEmitter(Request.prototype);\nfor (var key in requestBase) {\n Request.prototype[key] = requestBase[key];\n}\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set responseType to `val`. Presently valid responseTypes are 'blob' and\n * 'arraybuffer'.\n *\n * Examples:\n *\n * req.get('/')\n * .responseType('blob')\n * .end(callback);\n *\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.responseType = function(val){\n this._responseType = val;\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass, options){\n if (!options) {\n options = {\n type: 'basic'\n }\n }\n\n switch (options.type) {\n case 'basic':\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n break;\n\n case 'auto':\n this.username = user;\n this.password = pass;\n break;\n }\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach('content', new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n this._getFormData().append(field, file, filename || file.name);\n return this;\n};\n\nRequest.prototype._getFormData = function(){\n if (!this._formData) {\n this._formData = new root.FormData();\n }\n return this._formData;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n fn(err, res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Request has been terminated\\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');\n err.crossDomain = true;\n\n err.status = this.status;\n err.method = this.method;\n err.url = this.url;\n\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype._timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Compose querystring to append to req.url\n *\n * @api private\n */\n\nRequest.prototype._appendQueryString = function(){\n var query = this._query.join('&');\n if (query) {\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = request.getXHR();\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n\n // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n // result in the error \"Could not complete the operation due to error c00c023f\"\n var status;\n try { status = xhr.status } catch(e) { status = 0; }\n\n if (0 == status) {\n if (self.timedout) return self._timeoutError();\n if (self._aborted) return;\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n var handleProgress = function(direction, e) {\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n }\n e.direction = direction;\n self.emit('progress', e);\n }\n if (this.hasListeners('progress')) {\n try {\n xhr.onprogress = handleProgress.bind(null, 'download');\n if (xhr.upload) {\n xhr.upload.onprogress = handleProgress.bind(null, 'upload');\n }\n } catch(e) {\n // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n // Reported here:\n // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n }\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.timedout = true;\n self.abort();\n }, timeout);\n }\n\n // querystring\n this._appendQueryString();\n\n // initiate request\n if (this.username && this.password) {\n xhr.open(this.method, this.url, true, this.username, this.password);\n } else {\n xhr.open(this.method, this.url, true);\n }\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {\n // serialize stuff\n var contentType = this._header['content-type'];\n var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];\n if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n if (this._responseType) {\n xhr.responseType = this._responseType;\n }\n\n // send stuff\n this.emit('request', this);\n\n // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)\n // We need null here if data is undefined\n xhr.send(typeof data !== 'undefined' ? data : null);\n return this;\n};\n\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * OPTIONS query to `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.options = function(url, data, fn){\n var req = request('OPTIONS', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nfunction del(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\nrequest['del'] = del;\nrequest['delete'] = del;\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} [data]\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} [data]\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n","/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return null !== obj && 'object' === typeof obj;\n}\n\nmodule.exports = isObject;\n","/**\n * Module of mixed-in functions shared between node and client code\n */\nvar isObject = require('./is-object');\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nexports.clearTimeout = function _clearTimeout(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Override default response body parser\n *\n * This function will be called to convert incoming data into request.body\n *\n * @param {Function}\n * @api public\n */\n\nexports.parse = function parse(fn){\n this._parser = fn;\n return this;\n};\n\n/**\n * Override default request body serializer\n *\n * This function will be called to convert data set via .send or .attach into payload to send\n *\n * @param {Function}\n * @api public\n */\n\nexports.serialize = function serialize(fn){\n this._serializer = fn;\n return this;\n};\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nexports.timeout = function timeout(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Promise support\n *\n * @param {Function} resolve\n * @param {Function} reject\n * @return {Request}\n */\n\nexports.then = function then(resolve, reject) {\n if (!this._fullfilledPromise) {\n var self = this;\n this._fullfilledPromise = new Promise(function(innerResolve, innerReject){\n self.end(function(err, res){\n if (err) innerReject(err); else innerResolve(res);\n });\n });\n }\n return this._fullfilledPromise.then(resolve, reject);\n}\n\nexports.catch = function(cb) {\n return this.then(undefined, cb);\n};\n\n/**\n * Allow for extension\n */\n\nexports.use = function use(fn) {\n fn(this);\n return this;\n}\n\n\n/**\n * Get request header `field`.\n * Case-insensitive.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nexports.get = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Get case-insensitive header `field` value.\n * This is a deprecated internal API. Use `.get(field)` instead.\n *\n * (getHeader is no longer used internally by the superagent code base)\n *\n * @param {String} field\n * @return {String}\n * @api private\n * @deprecated\n */\n\nexports.getHeader = exports.get;\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n * Case-insensitive.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nexports.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n * Case-insensitive.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n */\nexports.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Write the field `name` and `val`, or multiple fields with one object\n * for \"multipart/form-data\" request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n *\n * request.post('/upload')\n * .field({ foo: 'bar', baz: 'qux' })\n * .end(callback);\n * ```\n *\n * @param {String|Object} name\n * @param {String|Blob|File|Buffer|fs.ReadStream} val\n * @return {Request} for chaining\n * @api public\n */\nexports.field = function(name, val) {\n\n // name should be either a string or an object.\n if (null === name || undefined === name) {\n throw new Error('.field(name, val) name can not be empty');\n }\n\n if (isObject(name)) {\n for (var key in name) {\n this.field(key, name[key]);\n }\n return this;\n }\n\n // val should be defined now\n if (null === val || undefined === val) {\n throw new Error('.field(name, val) val can not be empty');\n }\n this._getFormData().append(name, val);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\nexports.abort = function(){\n if (this._aborted) {\n return this;\n }\n this._aborted = true;\n this.xhr && this.xhr.abort(); // browser\n this.req && this.req.abort(); // node\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nexports.withCredentials = function(){\n // This is browser-only functionality. Node side is no-op.\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Set the max redirects to `n`. Does noting in browser XHR implementation.\n *\n * @param {Number} n\n * @return {Request} for chaining\n * @api public\n */\n\nexports.redirects = function(n){\n this._maxRedirects = n;\n return this;\n};\n\n/**\n * Convert to a plain javascript object (not JSON string) of scalar properties.\n * Note as this method is designed to return a useful non-this value,\n * it cannot be chained.\n *\n * @return {Object} describing method, url, and data of this request\n * @api public\n */\n\nexports.toJSON = function(){\n return {\n method: this.method,\n url: this.url,\n data: this._data,\n headers: this._header\n };\n};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nexports._isHost = function _isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Send `data` as the request body, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"}')\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nexports.send = function(data){\n var obj = isObject(data);\n var type = this._header['content-type'];\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n // default to x-www-form-urlencoded\n if (!type) this.type('form');\n type = this._header['content-type'];\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj || this._isHost(data)) return this;\n\n // default to json\n if (!type) this.type('json');\n return this;\n};\n","// The node and browser modules expose versions of this with the\n// appropriate constructor function bound as first argument\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(RequestConstructor, method, url) {\n // callback\n if ('function' == typeof url) {\n return new RequestConstructor('GET', method).end(url);\n }\n\n // url first\n if (2 == arguments.length) {\n return new RequestConstructor('GET', method);\n }\n\n return new RequestConstructor(method, url);\n}\n\nmodule.exports = request;\n"],"sourceRoot":""}