Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
__super__.call(self, fn);
return;
}
query = self._query.join('&');
timeout = self._timeout;
// store callback
self._callback = fn || noop;
// timeout
if (timeout && !self._timer) {
self._timer = setTimeout(function(){
cancelRequest.call(self);
}, timeout);
}
if (query) {
query = superagent.serializeObject(query);
self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
}
// send stuff
self.emit('request', self);
if ( !self.requestType['options'].async ) {
sendXhrSync.call(self);
}
else if ( reqType === 'jsonp' ) {
sendJsonp.call(self);
}
else if ( reqType === 'beacon' ) {
sendBeacon.call(self);
}
return self;
};
// timeout
if (timeout) {
xhr.timeout = timeout;
}
if (redirects != null) {
this.redirects(redirects);
}
if (validatesSecureCertificate != null) {
xhr.validatesSecureCertificate = this._validatesSecureCertificate
}
// querystring
if (query) {
query = request.serializeObject(query);
this.url += ~this.url.indexOf('?')
? '&' + query
: '?' + query;
}
// initiate request
xhr.open(this.method, this.url, true);
// CORS
if (this._withCredentials) xhr.withCredentials = true;
// body
if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
// serialize stuff
var serialize = request.serialize[this.getHeader('Content-Type')];
if (serialize) data = serialize(data);
query,
timeout;
if ( ('GET' !== self['method'] || reqType === 'xhr' ) && self.requestType['options'].async ) {
__super__.call(self, fn);
return;
}
query = self._query.join('&');
timeout = self._timeout;
self._callback = fn || noop;
if (timeout && !self._timer) {
self._timer = setTimeout(function(){
cancelRequest.call(self);
}, timeout);
}
if (query) {
query = superagent.serializeObject(query);
self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
}
self.emit('request', self);
if ( !self.requestType['options'].async ) {
sendXhrSync.call(self);
}
else if ( reqType === 'jsonp' ) {
sendJsonp.call(self);
}
else if ( reqType === 'beacon' ) {
sendBeacon.call(self);
}
return self;
};
return request;
query,
timeout;
if ( ('GET' !== self['method'] || reqType === 'xhr' ) && self.requestType['options'].async ) {
__super__.call(self, fn);
return;
}
query = self._query.join('&');
timeout = self._timeout;
self._callback = fn || noop;
if (timeout && !self._timer) {
self._timer = setTimeout(function(){
abortRequest.call(self);
}, timeout);
}
if (query) {
query = superagent.serializeObject(query);
self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
}
self.emit('request', self);
if ( !self.requestType['options'].async ) {
sendXhrSync.call(self);
}
else if ( reqType === 'jsonp' ) {
sendJsonp.call(self);
}
else if ( reqType === 'beacon' ) {
sendBeacon.call(self);
}
return self;
};
return request;
query,
timeout;
if ( ('GET' !== self['method'] || reqType === 'xhr' ) && self.requestType['options'].async ) {
__super__.call(self, fn);
return;
}
query = self._query.join('&');
timeout = self._timeout;
self._callback = fn || noop;
if (timeout && !self._timer) {
self._timer = setTimeout(function(){
cancelRequest.call(self);
}, timeout);
}
if (query) {
query = superagent.serializeObject(query);
self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
}
self.emit('request', self);
if ( !self.requestType['options'].async ) {
sendXhrSync.call(self);
}
else if ( reqType === 'jsonp' ) {
sendJsonp.call(self);
}
else if ( reqType === 'beacon' ) {
sendBeacon.call(self);
}
return self;
};
return request;
query,
timeout;
if ( ('GET' !== self['method'] || reqType === 'xhr' ) && self.requestType['options'].async ) {
__super__.call(self, fn);
return;
}
query = self._query.join('&');
timeout = self._timeout;
self._callback = fn || noop;
if (timeout && !self._timer) {
self._timer = setTimeout(function(){
abortRequest.call(self);
}, timeout);
}
if (query) {
query = superagent.serializeObject(query);
self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
}
self.emit('request', self);
if ( !self.requestType['options'].async ) {
sendXhrSync.call(self);
}
else if ( reqType === 'jsonp' ) {
sendJsonp.call(self);
}
else if ( reqType === 'beacon' ) {
sendBeacon.call(self);
}
return self;
};
return request;