尝试通过网址发布请求连接到网络服务。
String SIGNATURE = "signature"; //(This data is huge)
String url = "someUrl";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
//add reuqest header
con.setRequestMethod("POST");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setRequestProperty("PS-Sign",SIGNATURE);
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
getInputStream()
抛出异常:服务器返回HTTP响应代码:400为URL:...
我知道因为多种原因可能会返回400,但在这种情况下我100%知道这是由' SIGNATURE'头。字符是可以的,它的大小会导致错误的请求。
如何增加尺寸限制?