http client showing "unsupported protocol scheme"

977 views
Skip to first unread message

Aft nix

unread,
Dec 5, 2015, 9:47:22 AM12/5/15
to golang-nuts
This trivial code is not working...

    req, err := http.NewRequest("GET", "http//x.y.info/togx.php", nil)
    if err != nil {
    log.Println(err)
    return
    }
    req.Header.Add("Accept", "text/html")
    q := req.URL.Query()
    q.Add("toga", strings.TrimSpace(strings.Split(msg, "~")[1]))
    req.URL.RawQuery = q.Encode()
    resp, err := client.Do(req)
    if err != nil {
    log.Println(err)
    return
    }


Sample input : 

    msg := "xml~1010"

Output :

    tlsserver.go:64: Get http//x.y.info/togx.php?toga=1010: unsupported protocol scheme ""

Curl session:

    *   Trying x.y.z.w...
    * Connected to togorful.info (x.y.z.w) port 80 (#0)
    > GET /togx.php?toga=1010 HTTP/1.1
    > Host: x.y.info
    > User-Agent: curl/7.43.0
    > Accept: */*
    > 
    < HTTP/1.1 200 OK
    < Date: Sat, 05 Dec 2015 12:50:54 GMT
    < Server: Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4
    < X-Powered-By: PHP/5.4.29
    < Connection: close
    < Transfer-Encoding: chunked
    < Content-Type: text/html

Dave Cheney

unread,
Dec 5, 2015, 9:50:48 AM12/5/15
to golang-nuts
You're missing the colon between http and //
Reply all
Reply to author
Forward
0 new messages