获取http请求的request中的content-type，如没有设置则设置为默认的
{@link com.baidu.beidou.navi.constant.NaviCommonConstant#DEFAULT_PROTOCAL_CONTENT_TYPE}

@param httpServletRequest
@return
6332
protected String getProtocolByHttpContentType(HttpServletRequest httpServletRequest) {
        if (StringUtil.isEmpty(httpServletRequest.getContentType())) {
            throw new InvalidRequestException("Rpc protocol invalid");
        }
        String protocol = httpServletRequest.getContentType().split(";")[0];
        if (protocol == null) {
            protocol = NaviCommonConstant.DEFAULT_PROTOCAL_CONTENT_TYPE;
            if (LOG.isDebugEnabled()) {
                LOG.debug("Content-type set to default value "
                        + NaviCommonConstant.DEFAULT_PROTOCAL_CONTENT_TYPE);
            }
        } else {
            protocol = protocol.toLowerCase();
        }
        return protocol;
    }
65939
protected Optional<MutableHttpResponse<?>> handleRequest(HttpRequest request) {
        HttpHeaders headers = request.getHeaders();
        Optional<String> originHeader = headers.getOrigin();
        if (originHeader.isPresent()) {

            String requestOrigin = originHeader.get();
            boolean preflight = CorsUtil.isPreflightRequest(request);

            Optional<CorsOriginConfiguration> optionalConfig = getConfiguration(requestOrigin);

            if (optionalConfig.isPresent()) {
                CorsOriginConfiguration config = optionalConfig.get();

                HttpMethod requestMethod = request.getMethod();

                List<HttpMethod> allowedMethods = config.getAllowedMethods();

                if (!isAnyMethod(allowedMethods)) {
                    HttpMethod methodToMatch = preflight ? headers.getFirst(ACCESS_CONTROL_REQUEST_METHOD, HttpMethod.class).orElse(requestMethod) : requestMethod;
                    if (allowedMethods.stream().noneMatch(method -> method.equals(methodToMatch))) {
                        return Optional.of(HttpResponse.status(HttpStatus.FORBIDDEN));
                    }
                }

                if (preflight) {
                    Optional<List> accessControlHeaders = headers.get(ACCESS_CONTROL_REQUEST_HEADERS, Argument.of(List.class, String.class));

                    List<String> allowedHeaders = config.getAllowedHeaders();

                    if (!isAny(allowedHeaders) && accessControlHeaders.isPresent()) {
                        if (!accessControlHeaders.get().stream()
                            .allMatch(header -> allowedHeaders.stream()
                                .anyMatch(allowedHeader -> allowedHeader.equals(header.toString().trim())))) {
                            return Optional.of(HttpResponse.status(HttpStatus.FORBIDDEN));
                        }
                    }

                    MutableHttpResponse<Object> ok = HttpResponse.ok();
                    handleResponse(request, ok);
                    return Optional.of(ok);
                }
            }
        }

        return Optional.empty();
    }
1070390
public <T extends Serializable> T getContentFromType() throws FoxHttpResponseException {
        try {
            return getContent((Class<T>) Class.forName(this.type), false);
        } catch (FoxHttpResponseException e) {
            throw e;
        } catch (Exception e) {
            throw new FoxHttpResponseException(e);
        }

    }
139525
public static byte getSerializeTypeByContentType(String contentType) throws SofaRpcException {
        if (StringUtils.isNotBlank(contentType)) {
            String ct = contentType.toLowerCase();
            if (ct.contains("text/plain") || ct.contains("text/html") || ct.contains("application/json")) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_JSON);
            } else if (ct.contains(RpcConstants.SERIALIZE_PROTOBUF)) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_PROTOBUF);
            } else if (ct.contains(RpcConstants.SERIALIZE_HESSIAN)) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_HESSIAN2);
            }
        }
        throw new SofaRpcException(RpcErrorType.SERVER_DESERIALIZE, "Unsupported content type " + contentType
            + " in http protocol, please set HTTP HEAD: '" + RemotingConstants.HEAD_SERIALIZE_TYPE + "'.");
    }
1045675
@Override
  public String getProtocol(HttpServletRequest request) {
    String proto = request.getHeader(X_FORWARED_PROTO);
    if( proto != null ) return proto;
    return super.getProtocol(request);
  }
251107
public static String getRequestEncoding(ServletRequest request) {
		String requestEncoding = request.getCharacterEncoding();
		return requestEncoding != null ? requestEncoding : DEFAULT_REQUEST_ENCODING;
	}
1270527
protected RequestEntity createBinaryRequestContent(HTTPRequest httpRequest)
    {
        RequestEntity requestEntity=null;
        byte[] contentBinary=httpRequest.getContentAsBinary();
        if(contentBinary!=null)
        {
            requestEntity=new ByteArrayRequestEntity(contentBinary,"binary/octet-stream");
        }
        
        return requestEntity;
    }
422615
@SuppressWarnings("null")
  private boolean accepts(SlingHttpServletRequest request) {
    return request.getMethod().equalsIgnoreCase(METHOD_GET)
        && request.getResource() != null
        && StringUtils.equals(request.getResource().getValueMap().get(JCR_PRIMARYTYPE, String.class), NT_FILE);
  }
797320
private static String getResponseMimeType(final HttpResponse httpHeadResponse) {
        Header contentTypeHeader = httpHeadResponse.getFirstHeader("Content-Type");
        if (contentTypeHeader != null) {
            String contentType = contentTypeHeader.getValue();
            if (contentType != null) {
                try {
                    return ContentType.parse(contentType).getMimeType();
                } catch (ParseException | UnsupportedCharsetException exception) {
                    return contentType.split(";")[0].trim();
                }
            }
        }

        return ContentType.DEFAULT_TEXT.getMimeType();
    }
112751
@SuppressWarnings("Duplicates")
    public static Optional<Charset> resolveCharset(HttpMessage<?> request) {
        try {
            Optional<Charset> contentTypeCharset = request
                .getContentType()
                .flatMap(contentType ->
                    contentType.getParameters()
                        .get(MediaType.CHARSET_PARAMETER)
                        .map(Charset::forName)
                );

            if (contentTypeCharset.isPresent()) {
                return contentTypeCharset;
            } else {
                return request
                    .getHeaders()
                    .findFirst(HttpHeaders.ACCEPT_CHARSET)
                    .map(text -> {
                        int len = text.length();
                        if (len == 0 || (len == 1 && text.charAt(0) == '*')) {
                            return StandardCharsets.UTF_8;
                        }
                        if (text.indexOf(';') > -1) {
                            text = text.split(";")[0];
                        }
                        if (text.indexOf(',') > -1) {
                            text = text.split(",")[0];
                        }
                        try {
                            return Charset.forName(text);
                        } catch (Exception e) {
                            // unsupported charset, default to UTF-8
                            return StandardCharsets.UTF_8;
                        }
                    });
            }
        } catch (UnsupportedCharsetException e) {
            return Optional.empty();
        }
    }
52797
public Response contentType(String contentType) {
        checkCommitted();

        header(HttpConstants.Header.CONTENT_TYPE, contentType);
        httpServletResponse.setContentType(contentType);

        return this;
    }
1267986
@Override
    public IPortalUrlBuilder getDefaultUrl(HttpServletRequest request) {
        final IUrlNodeSyntaxHelper urlNodeSyntaxHelper =
                this.urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request);
        final String defaultLayoutNodeId = urlNodeSyntaxHelper.getDefaultLayoutNodeId(request);
        return this.getPortalUrlBuilderByLayoutNode(request, defaultLayoutNodeId, UrlType.RENDER);
    }
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;
	}
1148154
@Override
    public String getContentType() {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getContentType();
        return null;
    }
282139
@Override
    public String getContentType() {
	URLConnection connection = null;
	try {
	    connection = url.openConnection();
	}
	catch (IOException e) {}
	if (connection == null) return DEFAULT_CONTENT_TYPE;

	return connection.getContentType();

    }
343842
@Override
    public ContentPattern<?> forRequest(Request request) {
        final String mimeType = request.getHeaders().getContentTypeHeader().mimeTypePart();
        if (mimeType != null) {
            if (mimeType.contains("json")) {
                return new EqualToJsonPattern(request.getBodyAsString(), ignoreArrayOrder, ignoreExtraElements);
            } else if (mimeType.contains("xml")) {
                return new EqualToXmlPattern(request.getBodyAsString());
            } else if (mimeType.equals("multipart/form-data")) {
                // TODO: Need to add a matcher that can handle multipart data properly. For now, just always match
                return new AnythingPattern();
            } else if (!determineIsTextFromMimeType(mimeType)) {
                return new BinaryEqualToPattern(request.getBody());
            }
        }

        return new EqualToPattern(request.getBodyAsString(), caseInsensitive);
    }
702645
@RequestMapping(produces = HttpHeaders.JSONAPI_CONTENT_TYPE)
	@ResponseBody
	public ResponseEntity<Document> errorToJsonApi(HttpServletRequest request) {
		Map<String, Object> body = getErrorAttributes(request,
				isIncludeStackTrace(request, MediaType.ALL));
		HttpStatus status = getStatus(request);

		ErrorDataBuilder errorDataBuilder = ErrorData.builder();
		for (Map.Entry<String, Object> attribute : body.entrySet()) {
			if (attribute.getKey().equals("status")) {
				errorDataBuilder.setStatus(attribute.getValue().toString());
			} else if (attribute.getKey().equals("error")) {
				errorDataBuilder.setTitle(attribute.getValue().toString());
			} else if (attribute.getKey().equals("message")) {
				errorDataBuilder.setDetail(attribute.getValue().toString());
			} else {
				errorDataBuilder.addMetaField(attribute.getKey(), attribute.getValue());
			}
		}
		Document document = new Document();
		document.setErrors(Arrays.asList(errorDataBuilder.build()));
		return new ResponseEntity<>(document, status);
	}