Skip to content

net/url: Parse should normalize scheme, host to lower case #3913

@gopherbot

Description

@gopherbot

by legoff.laurent:

What steps will reproduce the problem?
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() {
    rdfUrl := "http://purl.org/dc/elements/1.1/";
    _, err := GetRDF(rdfUrl, true)
    if err != nil {
        fmt.Println(err)
    }
}

What is the expected output?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
    <!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
    <!ENTITY rdfsns 'http://www.w3.org/2000/01/rdf-schema#'>
    <!ENTITY dcns 'http://purl.org/dc/elements/1.1/'>
    <!ENTITY dctermsns 'http://purl.org/dc/terms/'>
    <!ENTITY dctypens 'http://purl.org/dc/dcmitype/'>
    <!ENTITY dcamns 'http://purl.org/dc/dcam/'>
    <!ENTITY skosns 'http://www.w3.org/2004/02/skos/core#'>
    <!ENTITY owlns 'http://www.w3.org/2002/07/owl#'>
]>
<rdf:RDF...

What do you see instead?
Get HTTP://dublincore.org/documents/2012/06/14/dcmi-terms/: unsupported protocol scheme
"HTTP"

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
windows 7 64bit 

Which version are you using?  (run 'go version')
go version go1

Please provide any additional information below.
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.
https://groups.google.com/d/topic/golang-nuts/IZMji-U09Mg/discussion

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions