Reputation: 6259
I wrote a class for my HTTP-Request. My proplem is that although in several lines of this code i added:
httpConn.setRequestMethod("PUT");
My code still performs POST-Request instead of PUT-Request! What do i wrong? Thanks!
public MultipartUtility(String requestURL, String charset)
throws IOException {
this.charset = charset;
// creates a unique boundary based on time stamp
boundary = "===" + System.currentTimeMillis() + "===";
URL url = new URL(requestURL);
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setUseCaches(false);
httpConn.setRequestMethod("PUT");
httpConn.setDoOutput(true); // indicates POST method
httpConn.setRequestMethod("PUT");
httpConn.setDoInput(true);
httpConn.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + boundary);
httpConn.setRequestProperty("User-Agent", "CodeJava Agent");
httpConn.setRequestProperty("Test", "Bonjour");
outputStream = httpConn.getOutputStream();
writer = new PrintWriter(new OutputStreamWriter(outputStream, charset),
true);
}
Upvotes: 1
Views: 63
Reputation: 9429
httpConn.setUseCaches(false);
can effect this result. I am not sure PUT
can provide this feature
Upvotes: 1