flickr / yakbak

Record and playback HTTP responses
MIT License
1.06k stars 84 forks source link

Added options to ignore cookie headers for tape hash creation and recording a specific range of status codes #22

Open DylanFC opened 8 years ago

DylanFC commented 8 years ago

I added the following options to suit my particular needs: options.recordStatusCodes: Array of integers length 2, e.g. [200, 300] options.ignoreCookies: true|false

I'm only interested in recording status codes of successful requests, so I'm using this with the range [200,300] in case there are any backend issues when a tape doesn't already exist.

Moreover, my backend uses cookie based sessions so I have to authenticate before making a request to the server. However I don't want to authenticate if there is already a tape recorded. Therefore I need the tape hashes to be created without the cookie header playing a part, as subsequent requests will not have this cookie and therefore would not get the tape that was saved.

Thought these options might be helpful, and thanks for creating this!

king4sam commented 6 years ago

hey @DylanFC I got a similar problem I only care about the request url, however the cookie in header would also effect the original hashcode. It make yakbak thought that the request is different every time even they have the same request URL. Finally, I found that the self-define hashcode function in setting could solve the problem. for my example, hash:function(req,body){ return req .url.hashcode(); } then the name of recorded tape would be the same if they are from same requestURL.

yahoocla commented 6 years ago

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! :smile: