If GET /index fails, retry in 500ms
This commit is contained in:
parent
56ba1e6404
commit
1f60dd56de
9
files.go
9
files.go
@ -122,9 +122,12 @@ func RecvFiles(senderAddr string) {
|
|||||||
// GET /index on sender's HTTP server
|
// GET /index on sender's HTTP server
|
||||||
response, err := http.Get(serverAddr + "/index")
|
response, err := http.Get(serverAddr + "/index")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
time.Sleep(500*time.Millisecond)
|
indexGetFailed := true
|
||||||
response, err = http.Get(serverAddr + "/index")
|
for indexGetFailed {
|
||||||
if err != nil { log.Fatal().Err(err).Msg("Error getting index") }
|
response, err = http.Get(serverAddr + "/index")
|
||||||
|
if err != nil { log.Fatal().Err(err).Msg("Error getting index") } else {indexGetFailed = false}
|
||||||
|
time.Sleep(500*time.Millisecond)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Close response body at the end of this function
|
// Close response body at the end of this function
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
Reference in New Issue
Block a user