Sfoglia il codice sorgente

only dump error when http is not 200 response. also created special http error.

master
Patrick Peng Sun 8 anni fa
parent
commit
0b5c98b94e
1 ha cambiato i file con 12 aggiunte e 7 eliminazioni
  1. +12
    -7
      upload.go

+ 12
- 7
upload.go Vedi File

@@ -103,16 +103,21 @@ func httpRaw(httpMethod, targetURL string, data []byte, headers map[string]strin
}
defer r.Body.Close()

dump, err := httputil.DumpResponse(r, true)
if err != nil {
log.Fatal(err)
}
fmt.Printf("dump : %s", dump)

b, _ := ioutil.ReadAll(r.Body)
resp = string(b)
log.Println(resp)

if r.StatusCode != 200 {
debugDumpHTTPResponse(r)
err = errorHTTPResponseNew(r, r.Header.Get("X-Status-Reason"))
}
//log.Println(resp)
return
}

func debugDumpHTTPResponse(r *http.Response) {
dump, e := httputil.DumpResponse(r, true)
if e != nil {
log.Fatal(e)
}
fmt.Printf("dump : %s", dump)
}

Loading…
Annulla
Salva