Skip to content
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

Client does not handle binary payloads due to std::string type and null termination #412

Closed
aweigold opened this issue Mar 27, 2015 · 2 comments

Comments

@aweigold
Copy link

When using get_payload, or get_raw_payload, a std::string is returned, however when receiving a binary payload, null characters terminate the string.

Would it be possible to add support for get_payload_bytes and get_raw_payload_bytes?

(I am working on trying a fix and will submit a pull request if I can do it, but my c++ is not as good as my Java.)

@zaphoyd
Copy link
Owner

zaphoyd commented Mar 27, 2015

std::string is not null terminated and can be used for binary data. The data() method can be used to retrieve a pointer to the data buffer and the size() method is used to retrieve the length of the buffer. The buffer returned by data() may contain null bytes as well as any other bytes.

@aweigold
Copy link
Author

Thanks, got confused with c strings... this is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants