Skip to content

Instantly share code, notes, and snippets.

@joaolsilva joaolsilva/http-mime.go
Last active Jun 22, 2018

Embed
What would you like to do?
malformed MIME header line: Content-Disposition = attachment; filename=file.asc
package main
import (
"io/ioutil"
"log"
"net/http"
"time"
)
const url = "http://ruby.streamguys.com:8120/status2.xsl?mount=/live"
func main() {
log.SetFlags(log.Flags() | log.Lshortfile)
client := http.Client{
Timeout: 10 * time.Second,
}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Printf("err: %v", err)
return
}
resp, err := client.Do(req)
if err != nil {
log.Printf("err: %v", err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Printf("err: %v", err)
return
}
log.Printf("Received %v bytes", len(b))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.