-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
The problem
My thread hangs when no body passed into PUT or POST params (I use url params only)
But everything is OK if I change method to GET
Possible solution
I suppose we need to do connection.setDoOutput() for PUT and POST methods regardless request content length: see HttpTemplate.java:172
if (contentLength > 0 || method == POST || method == PUT || method == DELETE) { connection.setDoOutput(true); connection.setDoInput(true); } connection.setRequestProperty("Content-Length", Integer.toString(contentLength));
Also we need to open and flush output stream here HttpTemplate.java:114
if (contentLength > 0 || method == POST || method == PUT || method == DELETE) { // Write the request body OutputStream out = connection.getOutputStream(); out.write(requestBody.getBytes(CHARSET_UTF_8)); out.flush(); }
Two changes above help me
Metadata
Metadata
Assignees
Labels
No labels