Fixed tests, made it try to retry without streamed uploads on chromium if using Get() or Post()
This commit is contained in:
parent
a060c22222
commit
f5b3297d9d
21
main.go
21
main.go
|
@ -655,7 +655,14 @@ func Get(url string) (response *Response, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !strings.HasPrefix(url, "https://") && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
}
|
||||||
response, err = Fetch.Do(request)
|
response, err = Fetch.Do(request)
|
||||||
|
if !request.DisableStreamedClient && err != nil && err.Error() == "Failed to fetch" && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
response, err = Fetch.Do(request)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,8 +671,15 @@ func Post(url string, contentType string, body io.Reader) (response *Response, e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !strings.HasPrefix(url, "https://") && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
}
|
||||||
request.Header.Add("Content-Type", contentType)
|
request.Header.Add("Content-Type", contentType)
|
||||||
response, err = Fetch.Do(request)
|
response, err = Fetch.Do(request)
|
||||||
|
if !request.DisableStreamedClient && err != nil && err.Error() == "Failed to fetch" && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
response, err = Fetch.Do(request)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +690,14 @@ func PostForm(url string, data url.Values) (response *Response, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
if !strings.HasPrefix(url, "https://") && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
}
|
||||||
response, err = Fetch.Do(request)
|
response, err = Fetch.Do(request)
|
||||||
|
if !request.DisableStreamedClient && err != nil && err.Error() == "Failed to fetch" && !js.Global().Get("chrome").IsUndefined() {
|
||||||
|
request.DisableStreamedClient = true
|
||||||
|
response, err = Fetch.Do(request)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func tryHead(url string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tryPost(url string, message string) error {
|
func tryPost(url string, message string) error {
|
||||||
response, err := jsFetch.Post(url, strings.NewReader(message))
|
response, err := jsFetch.Post(url, "text/plain", strings.NewReader(message))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue