[go-nuts] HTTP client bug: unsupported protocol scheme "HTTP"

6,374 views
Skip to first unread message

Laurent Le Goff

unread,
Aug 6, 2012, 11:08:48 AM8/6/12
to golang-nuts
Hi Gophers,
when I run this HTTP request I have the following error:
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func GetRDF(url string, printResult bool) ([]byte, error) {
request, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
request.Header.Add("Accept", "application/rdf+xml")
resp, err := http.DefaultClient.Do(request)
if err != nil {
return nil, err
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
rdfContent := string(content)
if printResult {
fmt.Println(rdfContent)
}
return content, nil
}

func main() {
_, err := GetRDF(rdfUrl, true)
if err != nil {
fmt.Println(err)
}
}


Get HTTP://dublincore.org/documents/2012/06/14/dcmi-terms/: unsupported protocol scheme "HTTP"

it seems that purl redirect the request http://purl.org/dc/elements/1.1/ to HTTP://dublincore.org/documents/2012/06/14/dcmi-terms/ but with an uppercase protocol scheme.

Do I have to fill an issue?

regards


Laurent LE GOFF

Patrick Mylund Nielsen

unread,
Aug 6, 2012, 11:22:38 AM8/6/12
to Laurent Le Goff, golang-nuts
I guess url.Parse could lowercase the proto, but I don't think this happens very often, so wondering if it's worth it.

I tried to reproduce it, but it seems to be lowercase:

# curl -i http://purl.org/dc/elements/1.1/
HTTP/1.1 302 Moved Temporarily
Date: Mon, 06 Aug 2012 15:18:44 GMT
Server: 1060 NetKernel v3.3 - Powered by Jetty
Content-Type: text/html; charset=iso-8859-1
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 277

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
    <HEAD>
        <TITLE>302 Found</TITLE>
    </HEAD>
    <BODY>
    <H1>Found</H1>
         The resource requested is available <A HREF="http://dublincore.org/2012/06/14/dcelements#">here</A>.<P>
    </BODY>
</HTML>

For what it's worth, RFC 3986 states:

6.2.2.1.  Case Normalization

   For all URIs, the hexadecimal digits within a percent-encoding
   triplet (e.g., "%3a" versus "%3A") are case-insensitive and therefore
   should be normalized to use uppercase letters for the digits A-F.

   When a URI uses components of the generic syntax, the component
   syntax equivalence rules always apply; namely, that the scheme and
   host are case-insensitive and therefore should be normalized to
   lowercase.  For example, the URI <HTTP://www.EXAMPLE.com/> is
   equivalent to <http://www.example.com/>.  The other generic syntax
   components are assumed to be case-sensitive unless specifically
   defined otherwise by the scheme (see Section 6.2.3).

Please do file an issue.

Best,
Patrick

Laurent Le Goff

unread,
Aug 6, 2012, 11:57:04 AM8/6/12
to Patrick Mylund Nielsen, golang-nuts
Reply all
Reply to author
Forward
0 new messages