Support for raw data in reply?
Thanks for the library. I was curious if there is any way to get the raw response in the reply. Digging through the code I notice you do a switch of the first char in the builders_factory and then do the individual reply construction in an appropriate builder. Keeping the raw response would be nice for building proxies, perhaps I've overlooked how to do that?
Hi,
I guess that, by raw response, you mean being able to get the response returned by the server, unparsed?
If so, unfortunately, this is currently not supported. Your understanding of the code is correct: when a reply is received, it is automatically parsed by the appropriate builder, then the parsed reply is forwarded to the command callback and the raw reply is dismissed.
I keep in mind your suggestion as it can be interesting to get that, though I would need to find a way to implement that in a non-breaking way and without affecting the performance (right now, the main advantage of dismissing the raw reply is to clear the buffer and reduce memory consumption on large transfers). However, I cannot give you any timeline for an implementation of such feature, though PR are welcomed at any time :)
Best
OK, thanks for the prompt response! Seems like maybe we could do a new raw builder and then add a is_raw() method to the reply. We could then just copy the response into the m_str in the reply and still clear out the buffer in fetch_str. I think that should work, the protocol is just text right?
The only part that seems like a pain would be the commands API and wiring it all in there. Perhaps only expose it via the low-level send() api and add it as an arg to the commands vector?
The main issue I got is that adding an additional parameter would be a huge breaking change. If I was to implement this, I would probably go with an additional attribute in the cpp_redis::reply object, like .get_raw_reply().
Another thing is: do you need the original raw reply or a reconstituted one would be good? I can also add an .to_raw_reply() is cpp_redis::reply that would convert the reply to a raw text reply.
Still, this would not solve it for the cpp_redis::subscriber that does not receive a reply as parameter, but just the published channel and the published message.