I am getting a response back as well as header responses and everything, but for some reason the body is empty:
https://repl.it/repls/HastyAggravatingArchitect
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
const url = "http://comicbookdb.com/search.php"
func main() {
request, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
fmt.Println(err.Error())
return
}
q := request.URL.Query()
q.Add("form_search", "Captain America")
q.Add("form_searchtype", "Character")
// http://comicbookdb.com/search.php?form_search=captain%20america&form_searchtype=Character
request.URL.RawQuery = q.Encode()
client := http.DefaultClient
response, err := client.Do(request)
fmt.Println(response.Header.Get("Date"))
fmt.Println(response.StatusCode)
fmt.Println(response.Header.Get("Server"))
fmt.Println(response.Body)
r, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(string(r))
}
I commented in the full URL so that you can check it out yourself and see that the response body should not be empty.