RESTClient's executeMethod() always sets a content-type, even when it probably shouldn't
Storycrafter opened this issue · comments
In the RESTClient, we have the execute request always setting a content type regardless of whether the actual content body is empty or not.
private Response executeMethod(HTTPMethod method, Map params, Closure content) {
Map requestParams = createRequestParams(params)
setDefaultAcceptParam(requestParams)
byte[] data = null
if (content) {
def contentBuilder = new ContentBuilder(defaultContentTypeHeader,defaultCharset).build(content)
setDefaultContentHeader(requestParams, contentBuilder.contentTypeHeader)
data = contentBuilder.data
}
According to the issue comments on this grails issue and as response to this stackoverflow query. That is very likely a problem for frameworks that don't nominally support this.
A simple check on the data length before setting the content type would likely improve RESTClient's standards compliance.
I'd be happy to supply a fix..