-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while parsing image content with vcr rawToChar() error #112
Comments
thx for this detailed report! However, I don't see the vcr and webmockr versions you're using, can you include that. |
I've updated my comment above but here are the versions of the two packages:
|
thanks! will have a look |
If you haven't tried yet, can you try using this option https://ropenscilabs.github.io/http-testing-book/vcr-configuration.html#config-preserve-exact-body-bytes and see if that helps. |
I tried but I get the same error: library("vcr")
#> Registered S3 method overwritten by 'httr':
#> method from
#> as.character.form_file crul
vcr::use_cassette("simple_test",{
httr::GET("https://gallica.bnf.fr/iiif/ark:/12148/btv1b9055204k/f1/full/1500,750/0/native.png")
}, preserve_exact_body_bytes = TRUE)
#> CrulAdapter enabled!
#> HttrAdapter enabled!
#> net connect allowed
#> Error in rawToChar(x$content): caractère nul au milieu de la chaîne : '‰PNG\r\n\032\n\0\0\0\rIHDR\0\0\005Ü\0\0\002î\020\0\0\0\0ÁÛWÓ\0\0\0\tpHYs\0\0=„\0\0=„\001Õ¬¯t\0\0\200\0IDATxÚ$œ\005X\024ïûõ-vgæ‰éؤKi\004\005»\vƒ\026\003±»ƒî\020\020\005DQ\f\024\fìîîîîîîþêûüþïÎå¥+»3OÜ÷9Ÿ³AG“î\035¾²{×Ü¢Ø\210‚ Ægƒ\005Ï©NŸ\034»8F8—5¨r\016³ßbÿÒ\t:·v®åîézÚ•qÛæ>Êé{ý‰.é>ŽÞ\rêÓ®÷ë'{\035ô2{ú{"/Þ'Èï¡ŸŸÿUÿé¾\017|×øÑ\036Ã\032¦\006T\004Î\f\030\0378)h\231ÿ<ïç\215¶5²ú-õ~ïëî\235à³?°]Ö>×½Ž{…x3\rÆ6(ôüàkð[ä³Á㉧λŸW\215·½ï\\ÿ\0ŸJßu¾+¼Z{®õ>ìÕß3ÌçŠ\177ŽïjïF^k½î{Å»ÅzFzA¯î><Ïz{{†¹\217oPâ½À;×}º\017ðÜë±×½\235ë†úÈeVýÚîbƒ‡\rN{TøÖ©oã|¹\201¾~yý¿ž~žË\\î¹'x.õ\230îÁyÕöþæE{\032¼ÿzOö¼ãáW_ñ|êiòÈh\220FÆciÐÄù®[\003ç\b'ÎùBýÞ>>ž”waƒïn›ëW{g6èåZÇCï1·~K·nõí|§4\230Ô Ì7Íû {•kvýî¾Çɹ"ê_kÐ˽бÔ+ÑiµÃOÇR‡\036¶\rl§;]²½b\215±«çpÌi‹Kmç$ÇT§^\016\025¶ý\0354ÇQNþŽM\235\032;\025Û‹†QNÛíV[Ê\034»¸\025ºrN\025î\017\035z:û:ç8‡¸Üp²s¸å²Õ!ß±“s\210ƒ`imwÞjc<e9m[`p5µ´Ýb{Ý6ÉvŠÞ:À¹ÌIt\nrhoß̶¶öÃî†\235§å“e\235u°õ°µ•íuÇEN\201ö׬ª9Þ.Ù¶Ý\b;ÆöµÝ\006ûFÖŸ\016#í\220S\200ó\033»\231Úr«‡Ý\037û^vKìg;6sLµ
#> ejecting cassette: simple_test
#> CrulAdapter disabled!
#> HttrAdapter disabled! Created on 2019-10-16 by the reprex package (v0.3.0) |
okay, thanks for trying that. hmm, i wouldn't think rawToChar is what you'd want for a png. So you get the image and then you pass the bytes to |
ahhhh, i see now. tried running vcr on bi_image in your pkg, and the error comes from vcr in the traceback. |
…that can not be converted to character
working on branch |
added further tests for thhe change added tests for utility fxns fixed some more bad urls
…that can not be converted to character
@Rekyt changes on master now - reinstall - let me know if it works now |
It does work now! Thank you so much! |
…, stub was still being recorded Jeroen Ooms (1): Fix pkgdown docs Scott Chamberlain (36): correct spelling in StubRegistry.R #57 work on mocking writing to disk to support crul/httr #57 mocking writing to disk is working now bump version add tests for mocking writing to disk #57 bump version add disk value in RequestSignature class & have set_body() within Response account for when disk used #57 change in crul adapter - when vcr loaded, when response recordable: tweak to crul adapter: make sure absolute path recorded in vcr cassette add a makefile adapter httr - add disk into the response add docs, rbuildignore docs bump to dev version remove curl adapter changes in news, as those cahnges are still on a branch remove mention of curl in readme as possible pkg as adapter for webmockr change Response class set_body method to set body as raw if raw passed in - ropensci/vcr#112 require dev vcr change book url in description file dont need certain vcr version remove oldrel build from travis file change makefile check directive fix #75 add request_registry_clear method to clear the request registry fix to StubbedRequest: on error e.g malformed input, stub was still being recorded clarify what webmockr_allow_net_connect does in man file #74 authenticate and other options for httr were being ignored update man file minor egs tweak readme update add example of writing to disk mocking #57 hide stuff fix #77 update to R6 docs fix for httr adapter to capture body and write_disk usage correctly, bump version revdep check update bump pkg version no email option udpate news, cran comments, bump to v0.5 and update codemeta.json
Hi @sckott 👋 ,
I am currently working on a small API package called
bnfimage
which goal is to be an R client for the French National Library Image database.I thought I could use vcr for the tests of the package, but I had trouble when recording the queries. The query returns an image (a png image in the example below), I can perfectly read it. But whenever I try to record it with vcr I have the error below because of the
rawToChar()
function. I can reproduce it by making the query and directly feeding it to rawToChar().I know it is not directly due to vcr, but is there a solution in case of API that return images? I looked through the different API packages you developed but couldn't find a similar example.
Reprex:
Created on 2019-10-12 by the reprex package (v0.3.0)
Thank you so much!
Matthias
Session info
The text was updated successfully, but these errors were encountered: