Skip to content

Commit

Permalink
[fix] check nil pointer headers in request marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
asciimoo committed Jun 29, 2018
1 parent 2e9f37b commit dc3a35f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ func (r *Request) Marshal() ([]byte, error) {
return nil, err
}
}
return json.Marshal(&serializableRequest{
URL: r.URL.String(),
Method: r.Method,
Body: body,
ID: r.ID,
Ctx: ctx,
Headers: *r.Headers,
})
sr := &serializableRequest{
URL: r.URL.String(),
Method: r.Method,
Body: body,
ID: r.ID,
Ctx: ctx,
}
if r.Headers != nil {
sr.Headers = *r.Headers
}
return json.Marshal(sr)
}

0 comments on commit dc3a35f

Please sign in to comment.