public class HttpUtils extends Object
| 构造器和说明 |
|---|
HttpUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static URI |
appendUri(URI baseUri,
String... pathComponents)
Append the given path to the given baseUri.
|
static String |
encodeParameters(Request<? extends BaseRequest> request,
Boolean forSignature)
Creates an encoded query string from all the parameters in the specified
request.
|
static String |
generateHostHeader(URI uri)
Returns a host header according to the specified URI.
|
static String |
getCanonicalQueryString(Map<String,List<String>> parameters,
boolean forSignature) |
static String |
getCanonicalURIPath(String path)
构造规范uri(用于签名)
|
static boolean |
isHttpVerbose() |
static boolean |
isJsonContentType(Request<? extends BaseRequest> request)
判断是否是json类型请求
|
static boolean |
isJsonResponse(String contentType)
判断是否是json类型
|
static boolean |
isUsingNonDefaultPort(URI uri)
Returns true if the specified URI is using a non-standard port (i.e. any port other than 80 for HTTP URIs or any
port other than 443 for HTTPS URIs).
|
static String |
normalize(String value)
Normalize a string for use in YOP web service APIs.
|
static String |
normalizePath(String path)
Normalize a string for use in url path.
|
static boolean |
useEmptyAsCanonicalQueryString(String httpMethod,
YopContentType contentType)
计算是否用采用空串("")作为签名时的CanonicalQueryString
|
static boolean |
usePayloadForQueryParameters(Request<? extends BaseRequest> request) |
public static boolean isHttpVerbose()
public static String normalizePath(String path)
Yop object key can contain arbitrary characters, which may result double slash in the url path. Apache http client will replace "//" in the path with a single '/', which makes the object key incorrect. Thus we replace "//" with "/%2F" here.
path - the path string to normalize.normalize(String)public static String normalize(String value)
All letters used in the percent-encoding are in uppercase.
value - the string to normalize.public static String generateHostHeader(URI uri)
uri - the URIpublic static boolean isUsingNonDefaultPort(URI uri)
uri - the URIpublic static String getCanonicalQueryString(Map<String,List<String>> parameters, boolean forSignature)
public static URI appendUri(URI baseUri, String... pathComponents)
This method will encode the given path but not the given baseUri.
baseUri - pathComponents - public static boolean usePayloadForQueryParameters(Request<? extends BaseRequest> request)
public static String encodeParameters(Request<? extends BaseRequest> request, Boolean forSignature)
request - The request containing the parameters to encode.forSignature - forSignature.public static boolean isJsonResponse(String contentType)
contentType - 内容类型public static boolean isJsonContentType(Request<? extends BaseRequest> request)
request - 内容类型public static String getCanonicalURIPath(String path)
path - public static boolean useEmptyAsCanonicalQueryString(String httpMethod, YopContentType contentType)
httpMethod - 请求方法contentType - 内容格式Copyright © 2024. All rights reserved.