Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Cast response body to string in binary mode. #13452

Closed
wants to merge 1 commit into from

Conversation

vitallium
Copy link
Collaborator

QVariantHelper expects body to be the same type as before conversion.
If target type doesn't match the source type, QVariantHelper will return 0.
We can't convert in this way: QString -> QVariant -> QByteArray
Instead we must use the following way: QString -> QVariant -> QString

Fixes: #13026

@JamesMGreene
Copy link
Collaborator

Why Latin-1 instead of UTF-8?

@vitallium
Copy link
Collaborator Author

@JamesMGreene because it's binary data. UTF-8 may double the output data.

@JamesMGreene
Copy link
Collaborator

Does the toString() call assume Latin-1?

@vitallium
Copy link
Collaborator Author

@JamesMGreene nop, it just converts (constructs) a QString.

@ariya
Copy link
Owner

ariya commented Aug 6, 2015

LGTM, although we probably need some sanity tests for that.

@zackw
Copy link
Contributor

zackw commented Aug 6, 2015

I wonder if this is why the existing binary-response test in webserver-spec.js is xfailed.

On Aug 6, 2015, at 2:19 AM, Ariya Hidayat [email protected] wrote:

LGTM, although we probably need some sanity tests for that.


Reply to this email directly or view it on GitHub.

@vitallium
Copy link
Collaborator Author

@zackw unfortunately no, I tried to run your sample with this patch, and it's still failing :(

QVariantHelper expects body to be the same type as before conversion.
If target type doesn't match the source type, QVariantHelper will return 0.
We can't convert in this way: QString > QVariant -> QByteArray
Instead we must use the following way: QString > QVariant -> QString

Fixes: ariya#13026
@vitallium vitallium force-pushed the fix-webserver-binary-mode branch from 6b9b2bf to deb7afa Compare August 6, 2015 19:11
@vitallium
Copy link
Collaborator Author

  • Add tests

@vitallium
Copy link
Collaborator Author

Landed in b1ed678

@vitallium vitallium closed this Sep 25, 2015
@vitallium vitallium deleted the fix-webserver-binary-mode branch September 25, 2015 11:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants