Skip to content

Commit

Permalink
Do not break session if got invalid HTTP Method
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenepaniot committed Sep 23, 2022
1 parent ef43eab commit b90a6cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pkg/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"log"
"os"
"sync"
"time"
Expand Down Expand Up @@ -55,9 +56,9 @@ func Replay(phasesStr string, silent, dryRun bool, timeout int) {

for scanner.Scan() {
req, err := unmarshalRequest(scanner.Bytes())

if err != nil {
panic(err)
log.Println("ERROR: ", err)
continue
}

if pacer.done {
Expand Down
7 changes: 3 additions & 4 deletions pkg/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package ripley
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -68,15 +67,15 @@ func unmarshalRequest(jsonRequest []byte) (*request, error) {
// Validate

if !validMethod(req.Method) {
return nil, errors.New(fmt.Sprintf("Invalid method: %s", req.Method))
return nil, fmt.Errorf("invalid method: %s", req.Method)
}

if req.Url == "" {
return nil, errors.New("Missing required key: url")
return nil, fmt.Errorf("missing required key: url")
}

if req.Timestamp.IsZero() {
return nil, errors.New("Missing required key: timestamp")
return nil, fmt.Errorf("missing required key: timestamp")
}

return req, nil
Expand Down

0 comments on commit b90a6cb

Please sign in to comment.