How do I perform an HTTP post in groovy using HTTPBuilder that uploads the raw bytes of a file without using multipart/form-data? Specifically, I want my request to look like this:
POST http://....
Host: myhost
Content-Length: numBytes
Proxy-Connection: Keep-Alive
Raw Data
you could send it as binary
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
def http = new HTTPBuilder('http://localhost:8080')
http.post(path:'/', body: new File('/etc/passwd').bytes, requestContentType: BINARY) { response ->
println response.statusLine
}