To make an HTTP request with a custom binary body in Go, you can use the net/http
package and the http.NewRequest()
function. The body of the request can be created using a byte slice or a bytes.Buffer. Here is an example code snippet:
main.go616 chars25 lines
In this example, we create a byte slice with some binary data, create a new http.Request
with the binary data as the body, set the Content-Type
header to application/octet-stream
(indicating that the body contains binary data), create an http.Client
, and send the request. Finally, we handle the response according to our needs.
gistlibby LogSnag