Skip to content

Commit

Permalink
Merge pull request #38 from seborama/Issue_37
Browse files Browse the repository at this point in the history
Remove serialisation of Path in the cassette
  • Loading branch information
seborama authored Dec 14, 2018
2 parents 38e6ac5 + 326cba2 commit 352bc42
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
9 changes: 5 additions & 4 deletions cassette.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type request struct {
Body []byte
}

// Request transforms internal request to a filter request.
// Request transforms internal "request" to a filter "Request".
func (r request) Request() Request {
res := Request{
Header: r.Header,
Expand Down Expand Up @@ -56,7 +56,7 @@ type response struct {
TLS *tls.ConnectionState
}

// Response returns the internal response to a filter response.
// Response returns the internal "response" to a filter "Response".
func (r response) Response(req Request) Response {
return Response{
req: req,
Expand Down Expand Up @@ -211,8 +211,9 @@ type Stats struct {

// cassette contains a set of tracks.
type cassette struct {
Name, Path string
Tracks []track
Name string
Path string `json:"-"`
Tracks []track

// stats is not exported since it doesn't need serialising
stats Stats
Expand Down
8 changes: 2 additions & 6 deletions govcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,10 @@ func cloneHeader(h http.Header) http.Header {
if h == nil {
return nil
}
// copy headers

copied := make(http.Header, len(h))
for k, v := range h {
vCopy := make([]string, len(v))
for i, value := range v {
vCopy[i] = value
}
copied[k] = v
copied[k] = append([]string{}, v...)
}
return copied
}
Expand Down
1 change: 0 additions & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func (r *RequestFilters) Prepend(filters ...RequestFilter) {
dst := make(RequestFilters, 0, len(filters)+len(src))
dst = append(dst, filters...)
*r = append(dst, src...)
return
}

// combined returns the filters as a single filter.
Expand Down
6 changes: 3 additions & 3 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ func (r *ResponseFilters) Prepend(filters ...ResponseFilter) {

// combined returns the filters as a single filter.
func (r ResponseFilters) combined() ResponseFilter {
return func(req Response) Response {
return func(resp Response) Response {
for _, filter := range r {
req = filter(req)
resp = filter(resp)
}
return req
return resp
}
}

0 comments on commit 352bc42

Please sign in to comment.