I'm performing the following request in golang:
request := &http.Request{
URL: url,
Body: requestBody, //io.ReadCloser containing the body
Method: http.MethodPost,
ContentLength: int64(len(postBody)),
Header: make(http.Header),
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
}
res, err := http.DefaultClient.Do(request)
//Printing the request:
dump, dumpErr := httputil.DumpRequest(request, true)
if dumpErr != nil {
log.Fatal("Cannot dump the request")
}
log.Println(string(dump))
I want the host to be specified also in the path of the post request. Is it possible?
Expected result:
POST "http://127.0.0.1:10019/system?action=add_servers" HTTP/1.1
Host: 127.0.0.1:10019
Accept: "*/*"
Connection: keep-alive
Actual result:
POST "/system?action=add_servers" HTTP/1.1
Host: 127.0.0.1:10019
Accept: "*/*"
Connection: keep-alive