You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This causes problems on the server that I'm trying to call. For some reason the server returns 500 each time I have Content-Type and Content-Transfer-Encoding included in the parts.
For now I solved this like this:
I copied a class from FormHttpMessageConverter and modified the private class MultipartHttpOutputMessage to ignore other headers in the writeHeaders method. private void writeHeaders() throws IOException {
if (!this.headersWritten) {
for (Map.Entry<String, List<String>> entry : this.headers.entrySet()) {
if (!entry.getKey().equals("Content-Disposition")) continue;
byte[] headerName = getBytes(entry.getKey());
for (String headerValueString : entry.getValue()) {
byte[] headerValue = getBytes(headerValueString);
this.outputStream.write(headerName);
this.outputStream.write(':');
this.outputStream.write(' ');
this.outputStream.write(headerValue);
writeNewLine(this.outputStream);
}
}
writeNewLine(this.outputStream);
this.headersWritten = true;
}
}
But there should be a better way.
Affects: 2.1.1
The text was updated successfully, but these errors were encountered:
Siavash Arya opened SWF-1732 and commented
I'm sending a Multipart request with RestTemplate and I realized that it include 3 headers for each part:
Forexample:
Content-Disposition: form-data; name="body"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
My body
This causes problems on the server that I'm trying to call. For some reason the server returns 500 each time I have Content-Type and Content-Transfer-Encoding included in the parts.
For now I solved this like this:
I copied a class from FormHttpMessageConverter and modified the private class MultipartHttpOutputMessage to ignore other headers in the writeHeaders method. private void writeHeaders() throws IOException {
if (!this.headersWritten) {
for (Map.Entry<String, List<String>> entry : this.headers.entrySet()) {
if (!entry.getKey().equals("Content-Disposition")) continue;
byte[] headerName = getBytes(entry.getKey());
for (String headerValueString : entry.getValue()) {
byte[] headerValue = getBytes(headerValueString);
this.outputStream.write(headerName);
this.outputStream.write(':');
this.outputStream.write(' ');
this.outputStream.write(headerValue);
writeNewLine(this.outputStream);
}
}
writeNewLine(this.outputStream);
this.headersWritten = true;
}
}
But there should be a better way.
Affects: 2.1.1
The text was updated successfully, but these errors were encountered: