if form paramter is null, it will use content-type of request.headers
352991
public HttpResponse doAction(HttpRequest request, String form, HttpMethod method)
        throws ClientException, ServerException {
        request.validate();
        
        // try refresh credentials if CredentialProvider set
        this.config.refreshCredentials();
        
        try {
            int retryTimes = 0;
            HttpResponse response = null;

            boolean httpInvoke = false;
            if (request instanceof HttpInvokeFunctionRequest) {
                httpInvoke = true;
            }

            do {
                if (!httpInvoke
                    || !ANONYMOUS.equals(((HttpInvokeFunctionRequest) request).getAuthType())) {
                    signRequest(request, form, method, httpInvoke);
                }

                PrepareUrl prepareUrl = prepareUrl(request.getPath(), request.getQueryParams());

                response = HttpResponse.getResponse(prepareUrl.getUrl(), request, method,
                    config.getConnectTimeoutMillis(), config.getReadTimeoutMillis());

                retryTimes++;

                if (httpInvoke) {
                    return response;
                }

            } while (500 <= response.getStatus() && AUTO_RETRY && retryTimes < MAX_RETRIES);

            if (response.getStatus() >= 500) {
                String requestId = response.getHeader(HeaderKeys.REQUEST_ID);
                String stringContent =
                    response.getContent() == null ? "" : new String(response.getContent());
                ServerException se;
                try {
                    se = new Gson().fromJson(stringContent, ServerException.class);
                } catch (JsonParseException e) {
                    se = new ServerException("InternalServiceError",
                        "Failed to parse response content", requestId);
                }
                se.setStatusCode(response.getStatus());
                se.setRequestId(requestId);
                throw se;
            } else if (response.getStatus() >= 300) {
                ClientException ce;
                if (response.getContent() == null) {
                    ce = new ClientException("SDK.ServerUnreachable",
                        "Failed to get response content from server");
                } else {
                    try {
                        ce = new Gson()
                            .fromJson(new String(response.getContent()), ClientException.class);
                    } catch (JsonParseException e) {
                        ce = new ClientException("SDK.ResponseNotParsable",
                            "Failed to parse response content", e);
                    }
                }
                if (ce == null) {
                    ce = new ClientException("SDK.UnknownError", "Unknown client error");
                }
                ce.setStatusCode(response.getStatus());
                ce.setRequestId(response.getHeader(HeaderKeys.REQUEST_ID));
                throw ce;
            }
            return response;
        } catch (InvalidKeyException exp) {
            throw new ClientException("SDK.InvalidAccessSecret",
                "Speicified access secret is not valid.");
        } catch (SocketTimeoutException exp) {
            throw new ClientException("SDK.ServerUnreachable",
                "SocketTimeoutException has occurred on a socket read or accept.");
        } catch (IOException exp) {
            throw new ClientException("SDK.ServerUnreachable",
                "Server unreachable: " + exp.toString());
        } catch (NoSuchAlgorithmException exp) {
            throw new ClientException("SDK.InvalidMD5Algorithm",
                "MD5 hash is not supported by client side.");
        } catch (URISyntaxException e) {
            throw new ClientException("SDK.InvalidURL", "url is not valid: " + e.getMessage());
        }
    }
947787
def get(self, url, params=None, headers=None, content=None, form_content=None):
        # type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
        
        request = self._request('GET', url, params, headers, content, form_content)
        request.method = 'GET'
        return request
417057
private static String getHeaderParam( final String value, final String paramName ) {
        if( value == null || value.length() == 0 )
            return null;

        final int length = value.length();
        int start = value.indexOf(';') + 1;
        if( start == 0 || start == length )
            return null;

        int end = value.indexOf(';', start);
        if( end == -1 )
            end = length;

        while( start < end ) {
            int nameEnd = value.indexOf('=', start);
            if( nameEnd != -1 && nameEnd < end && paramName.equals(value.substring(start, nameEnd).trim()) ) {
                String paramValue = value.substring(nameEnd + 1, end).trim();
                int valueLength = paramValue.length();
                if( valueLength != 0 )
                    if( valueLength > 2 && '"' == paramValue.charAt(0) && '"' == paramValue.charAt(valueLength - 1) )
                        return paramValue.substring(1, valueLength - 1);
                    else
                        return paramValue;
            }

            start = end + 1;
            end = value.indexOf(';', start);
            if( end == -1 )
                end = length;
        }

        return null;
    }
1062678
protected void doPostForm(String path, MultivaluedMap<String, String> formParams) throws ClientException {
        doPostForm(path, formParams, null);
    }
770372
static String getConsumedContentType(HttpServletRequest request) {
        String mimeType = firstNotNull(request.getParameter("format"), request
                .getContentType());

        return ((mimeType != null) ? mimeType.replace("application/xml",
                BaseRestResource.XML) : null);
    }
1306922
public CORSRequestType checkRequestType(final HttpServletRequest request) {
		CORSRequestType requestType = CORSRequestType.INVALID_CORS;
		if (request == null) {
			throw new IllegalArgumentException(
					"HttpServletRequest object is null");
		}
		String originHeader = request.getHeader(REQUEST_HEADER_ORIGIN);
		// Section 6.1.1 and Section 6.2.1
		if (originHeader != null) {
			if (originHeader.isEmpty()) {
				requestType = CORSRequestType.INVALID_CORS;
			} else if (!isValidOrigin(originHeader)) {
				requestType = CORSRequestType.INVALID_CORS;
			} else {
				String method = StringUtils.trimToEmpty(request.getMethod());
				if (HTTP_METHODS.contains(method)) {
					if ("OPTIONS".equals(method)) {
						String accessControlRequestMethodHeader
								= request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
						if (StringUtils.isNotBlank(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.PRE_FLIGHT;
						} else if (StringUtils.isWhitespace(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.INVALID_CORS;
						} else {
							requestType = CORSRequestType.ACTUAL;
						}
					} else if ("GET".equals(method) || "HEAD".equals(method)) {
						requestType = CORSRequestType.SIMPLE;
					} else if ("POST".equals(method)) {
						String contentType = request.getContentType();
						if (contentType != null) {
							contentType = contentType.toLowerCase().trim();
							if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES
									.contains(contentType)) {
								requestType = CORSRequestType.SIMPLE;
							} else {
								requestType = CORSRequestType.ACTUAL;
							}
						}
					} else if (COMPLEX_HTTP_METHODS.contains(method)) {
						requestType = CORSRequestType.ACTUAL;
					}
				}
			}
		} else {
			requestType = CORSRequestType.NOT_CORS;
		}

		return requestType;
	}
379823
function contentTypeHeader(type) {
    if (this._res.headersSent) return this.debug(
      'Headers already sent, ignoring content type change: %s', contentTypes[type]
    );

    this.contentType = contentTypes[type];
    this._res.setHeader('Content-Type', this.contentType);
  }
464631
def content_type(self):
        
        type_formencoded = "application/x-www-form-urlencoded"

        ctype = self.request.META.get('CONTENT_TYPE', type_formencoded)

        if type_formencoded in ctype:
            return None

        return ctype
296869
function validateRequestParams(type, params) {
        var validatedParams = null;

        params = params || {};

        //Don't validate if the formatting is done by the caller
        if (params.format === MESSAGE_FORMAT.LSP) {
            return params;
        }

        switch (type) {
            case ToolingInfo.LANGUAGE_SERVICE.START:
                {
                    if (hasValidProp(params, "rootPaths") || hasValidProp(params, "rootPath")) {
                        validatedParams = params;
                        validatedParams.capabilities = validatedParams.capabilities || false;
                    }
                    break;
                }
            case ToolingInfo.FEATURES.CODE_HINTS:
            case ToolingInfo.FEATURES.PARAMETER_HINTS:
            case ToolingInfo.FEATURES.JUMP_TO_DECLARATION:
            case ToolingInfo.FEATURES.JUMP_TO_DEFINITION:
            case ToolingInfo.FEATURES.JUMP_TO_IMPL:
                {
                    if (hasValidProps(params, ["filePath", "cursorPos"])) {
                        validatedParams = params;
                    }
                    break;
                }
            case ToolingInfo.FEATURES.CODE_HINT_INFO:
                {
                    validatedParams = params;
                    break;
                }
            case ToolingInfo.FEATURES.FIND_REFERENCES:
                {
                    if (hasValidProps(params, ["filePath", "cursorPos"])) {
                        validatedParams = params;
                        validatedParams.includeDeclaration = validatedParams.includeDeclaration || false;
                    }
                    break;
                }
            case ToolingInfo.FEATURES.DOCUMENT_SYMBOLS:
                {
                    if (hasValidProp(params, "filePath")) {
                        validatedParams = params;
                    }
                    break;
                }
            case ToolingInfo.FEATURES.PROJECT_SYMBOLS:
                {
                    if (hasValidProp(params, "query") && typeof params.query === "string") {
                        validatedParams = params;
                    }
                    break;
                }
            case ToolingInfo.LANGUAGE_SERVICE.CUSTOM_REQUEST:
                {
                    validatedParams = params;
                }
        }

        return validatedParams;
    }
96921
private void setHeaders(XMLHttpRequest xmlHttpRequest) throws RequestException {

        if ((headers != null) && (headers.size() > 0)) {
            for (Map.Entry<String, String> header : headers.entrySet()) {
                try {
                    xmlHttpRequest.setRequestHeader(header.getKey(), header.getValue());
                } catch (JavaScriptException e) {
                    throw new RequestException(e.getMessage());
                }
            }
        } else {
            xmlHttpRequest.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
        }
    }
771294
function(url, params, onsuccess, onfail) {
    var t = _typeof(params), cn = 'Content-Type', cv = 'application/';

    if (t == 'object') {
      params = _params_2_url(params);
      setRequestHeader(cn, cv + 'x-www-form-urlencoded');
    }
    else if (t == 'formdata') {} // for formdata type.
    else setRequestHeader(cn, cv + 'json');
    // if is string / formdata
    return request('POST', url, params, onsuccess, onfail);
  }
179014
function(url, next, headers, options) {
    var headerStruct = {
      'User-Agent': 'request'
    };

    var params = {
      url : url,
      method : 'GET'
    };

    if (headers) {
      for (var k in headers) {
        if (headers.hasOwnProperty(k)) {
          headerStruct[k] = headers[k];
        }
      }
    }

    params.headers = headerStruct;
    params.gzip = true;

    if (options) {
      for (var k in options) {
        if (options.hasOwnProperty(k)) {
          params[k] = options[k];
        }
      }
    }

    if (next) {
      request(params, function(error, res, body) {
          if (res && res.headers && -1 !== res.headers['content-type'].indexOf('json') || -1 !== res.headers['content-type'].indexOf('javascript')) {
            try {
              body = JSON.parse(body);
            } catch (e) {
              error = e.message;
            }
          }

          if (404 === res.statusCode) {
            next('Not Found', body, res.headers, res.statusCode);
          } else {
            next(error, body, res ? res.headers : null, res ? res.statusCode : null);
          }
        }
      );
    } else {
      return request(params);
    }
  }
896508
function POST(uri, params) {
	var form = new FormData();

	for (var i in params) {
		form.append(i, params[i]);
	}

	const requestURL = `${uri}`;
	log(`request URL: ${requestURL}`);

	return fetch(requestURL, { method: 'POST', compress: compress, body: form, headers: { 'Content-Type': 'multipart/form-data; boundary='+form.getBoundary() } })
    .then(function handleRequest(res) {
			const status = res.status;
			if (status != 200) {
				const error = new Error(`Request failed: ${status}`);
				error.status = status;
				throw error;
			}
			return res.json();
		})
		.catch(error => {
			log(`error: ${error}`);
			throw error;
		});
}
1030422
def set_form_data(params, sep = '&')
      self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
      self.content_type = 'application/x-www-form-urlencoded'
    end
747737
function submit(form_id) {
        var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
        var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'POST';
        var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { 'X-Requested-With': 'XMLHttpRequest' };

        this._checkInit(form_id);
        var request = new XMLHttpRequest();
        if (url === null) {
            if (document.forms[form_id].hasAttribute('action')) {
                url = document.forms[form_id].getAttribute('action');
            } else {
                //throw new Error('Form.submit() is missing 2nd URL argument');
                url = '';
            }
        }
        request.open(method, url);
        var p = new Promise(function (success, fail) {
            request.onload = function () {
                if (request.status === 200) {
                    success(request.responseText);
                } else {
                    fail(request);
                }
            };
        });
        for (var header in headers) {
            request.setRequestHeader(header, headers[header]);
        }
        this._collection[form_id].set('categories', [2, 3]);
        request.send(this.getFormDataObject(form_id));
        return p;
    }
1278919
public void checkContentName(final HttpServletRequest request) {
    String reqpar = request.getParameter(getContentNameRequestName());

    // Set to null if not found.
    setContentName(reqpar);
  }
1251685
function(request, parameters) {
	if (!parameters) {
		return;
	}

	var keys = Object.keys(parameters);
	var type = false;
	var value = null;
	var options = null;
	for (var i = keys.length - 1; i >= 0; i--) {
		value = parameters[keys[i]];
		options = null;

		if (value instanceof Object && value.type && value.hasOwnProperty('value')) {
			if (value.hasOwnProperty('options')) {
				options = value.options;
			}
			type = value.type;
			value = value.value;
		}
		else {
			type = exports.detectParameterType(value);
		}

		if (!(value instanceof Array)) {
			request.addParameter(keys[i], type, value, options);
			continue;
		}
	}
}