Using a file as body for a request?

15 views
Skip to first unread message

Pedro Nascimento

unread,
Mar 23, 2012, 3:27:42 PM3/23/12
to VCR Rubygem
If I want to use a file i.e. image as the content of a request, is
there any way to do it?

Thank you!

Myron Marston

unread,
Mar 23, 2012, 3:44:27 PM3/23/12
to VCR Rubygem
I'm not really sure what you're asking. VCR doesn't make requests for
you or restrict how you make them (except for the fact it only
supports certain ruby HTTP client libraries).

So yeah...if you're using an HTTP client library that supports using a
file's content as the body of a request, then you can do it. That has
nothing to do with VCR, though.

Am I misunderstanding your question?

Pedro Nascimento

unread,
Mar 23, 2012, 3:56:05 PM3/23/12
to vcr-...@googlegroups.com
Rephrasing in a better way: If I have a huge text file that I want to be the body of my response. Instead of pasting it into the yaml, can I do it in another way?

I have the feeling this might be more of a YAML question than a VCR question. :>

Myron Marston

unread,
Mar 23, 2012, 4:10:10 PM3/23/12
to VCR Rubygem
On Mar 23, 12:56 pm, Pedro Nascimento <pnascime...@gmail.com> wrote:
> Rephrasing in a better way: If I have a huge text file that I want to be
> the body of my response. Instead of pasting it into the yaml, can I do it
> in another way?
>
> I have the feeling this might be more of a YAML question than a VCR
> question. :>
>
> On Fri, Mar 23, 2012 at 16:44, Myron Marston <myron.mars...@gmail.com>wrote:

The phrasing of your question suggests you are managing/modifying the
VCR YAML files by hand. You can do this, of course, but VCR is
designed to be completely automatic in this regard. There are valid
reasons to manually change the YAML file but you shouldn't do it as a
matter of course.

If you want VCR to automatically store the response body in a separate
file, something like this should work:

https://gist.github.com/2174463

Caveats:

* I haven't tested that, so you may need to tweak it a bit to work.
* That assumes that each cassette will have only one HTTP
interaction. If you have multiple HTTP interactions in the same
cassette you will need to account for that some how and name the
response body files accordingly.

Pedro Nascimento

unread,
Mar 23, 2012, 4:12:44 PM3/23/12
to vcr-...@googlegroups.com
I'll take a look at it. Thank you very much!
Reply all
Reply to author
Forward
0 new messages