com.aliyun.auth.credentials.http.HttpRequest Maven / Gradle / Ivy
The newest version!
package com.aliyun.auth.credentials.http;
import com.aliyun.auth.credentials.utils.ParameterHelper;
import com.aliyun.core.utils.Configuration;
import java.io.IOException;
import java.util.*;
public class HttpRequest extends HttpMessage {
private Map immutableMap = new HashMap();
private static final String DEFAULT_USER_AGENT;
static {
String javaVersion = Configuration.getGlobalConfiguration().get("java.version");
String osName = Configuration.getGlobalConfiguration().get("os.name");
String osArch = Configuration.getGlobalConfiguration().get("os.arch");
String coreVersion = "unknown";
try {
Properties props = new Properties();
props.load(HttpRequest.class.getClassLoader().getResourceAsStream("core.properties"));
coreVersion = props.getProperty("sdk.project.version");
} catch (IOException e) {
e.printStackTrace();
}
DEFAULT_USER_AGENT = String.format("AlibabaCloud (%s; %s) Java/%s AsyncCredentials/%s TeaDSL/1",
"AlibabaCloud", osName, osArch, javaVersion, "AsyncCoreService", coreVersion);
}
public HttpRequest() {
setCommonParameter();
}
public HttpRequest(String url) {
super(url);
setCommonParameter();
}
private void setCommonParameter() {
this.immutableMap.put("Timestamp", ParameterHelper.getISO8601Time(new Date()));
this.immutableMap.put("SignatureNonce", ParameterHelper.getUniqueNonce());
this.immutableMap.put("SignatureMethod", "HMAC-SHA1");
this.immutableMap.put("SignatureVersion", "1.0");
this.putHeaderParameter("user-agent", DEFAULT_USER_AGENT);
}
public void setUrlParameter(String key, String value) {
this.immutableMap.put(key, value);
}
public String getUrlParameter(String key) {
return this.immutableMap.get(key);
}
public Map getUrlParameters() {
return Collections.unmodifiableMap(immutableMap);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy