Skip to content

Commit

Permalink
check for EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Payeur Levallois committed Apr 11, 2017
1 parent 4672d31 commit 49a0d1f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"math/rand"
Expand Down Expand Up @@ -89,6 +90,12 @@ func (h *HTTPSender) RRSend(body []byte) error {
if err := h.send(bodyReader); err != nil {
// Network error
if uerr, ok := err.(*url.Error); ok {
if uerr.Err == io.EOF {
log.Printf("Invalid body, skipping: %s", err)
log.Printf("%s\n", string(body))
return nil
}

if nerr, ok := uerr.Err.(*net.OpError); ok {
log.Printf("Network error, backing off sending: %s", nerr)
time.Sleep(time.Second)
Expand Down

0 comments on commit 49a0d1f

Please sign in to comment.