private function; called with a Request instance bound to `this`
function buildSuperagentRequest() {
	var req = superagent(this._method, this._buildUrl());

	if (this._agent){
		req.agent(this._agent);
	}

	req.set(this._headers);

	this._queryParams.forEach(params => req.query(params));

	var postParams = this._postParams;

	// convert params to FormData if the request type is form-data
	if (this._type === "form-data") {
		if (!SERVER_SIDE) {
			var formData = new FormData();
			if (postParams) {
				var paramKeys = Object.keys(postParams);
				paramKeys.forEach(key => {
					formData.append(key, postParams[key]);
				});
			}
			postParams = formData;
		} else {
			throw new Error(`ReactServerAgent.type("form-data") not allowed server-side`);
		}
	}

	// query parameters exist if there are more than one set
	// post parameters exist if the value is not null
	const hasQueryParams = (this._queryParams.length > 0),
		hasPostParams = (this._postParams !== null);

	if (hasPostParams) {
		// superagent has some weird, implicit file upload support
		// that only works if you don't set `type`.
		if (this._type && this._type !== 'form-data') {
			req.type(this._type);
		}

		req.send(postParams);
	}

	switch (this._method) {
		case 'GET':
		case 'HEAD':
			if (hasPostParams) {
				logger.warning(`Attempting a ${this._method} request with POST data (using SuperAgent's .send() function). This might result in a CORS preflight request`);
			}
			break;

		case 'POST':
		case 'PATCH':
		case 'PUT':
			if (hasQueryParams) {
				logger.info(`Attempting a ${this._method} request with query data (using SuperAgent's .query() function). This might not be what you want.`);
			}
			break;
	}

	if (this._timeout) {
		req.timeout(this._timeout);
	}

	// cache the internal request, so that we can cancel it
	// if necessary (see: `abort()`)
	this._superagentReq = req;

	return req;
}