You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue with interpreting "special characters" in the response body when exporting/importing simulations when the Content-Length header is present. I have observed that this won't occur when I manually remove the Content-Length field from the simulation file.
This can be demonstrated with a simple request to Google:
moth@debian:~/hoverfly$ ./hoverctl start
Hoverfly is now running
+------------+------+
| admin-port | 8888 |
| proxy-port | 8500 |
+------------+------+
moth@debian:~/hoverfly$ ./hoverctl mode capture --all-headers
Hoverfly has been set to capture mode and will capture all request headers
moth@debian:~/hoverfly$ curl -L --proxy localhost:8500 http://google.com --cacert cert.pem
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-AU"><head><meta content="text/html;>
[TRUNCATED FOR CLEANLINESS]
moth@debian:~/hoverfly$ ./hoverctl export simulation.json
Successfully exported simulation to simulation.json
moth@debian:~/hoverfly$ ./hoverctl stop
Hoverfly has been stopped
moth@debian:~/hoverfly$ ./hoverctl start
Hoverfly is now running
+------------+------+
| admin-port | 8888 |
| proxy-port | 8500 |
+------------+------+
moth@debian:~/hoverfly$ ./hoverctl import simulation.json
WARNING: Response contains incorrect Content-Length header on data.pairs[1].response, please correct or remove header
Now, the warning itself isn't so much of a problem seemingly (it's just a warning, and a valid one) but curl fails on that endpoint thereafter in simulation mode:
moth@debian:~/hoverfly$ curl -L --proxy localhost:8500 http://google.com --cacert cert.pem
curl: (18) transfer closed with 11194 bytes remaining to read
I spoke to @tommysitu on Glitter regarding this and he requested that I create an issue to explore this further. His comments regarding the problem:
Tommy Situ @tommysitu 03:33
It's to do with the encoding. When the body is exported and imported again, the string with special character Advertising\ufffdProgrammes is converted to Advertising�Programmes which results a mismatch content-length
Is this something that hoverfly should handle and/or is there something I should do here to handle these cases in a better way than just removing the Content-Length header for simulations where I encounter this problem?
The text was updated successfully, but these errors were encountered:
This issue happens during importing. The json unmarshaller convert \ufffd to � changes the length of the body. The stringify rune uses more bytes I think?
One possible fix is to make hoverfly returns a correct Content-Length header value by ignoring the one in the simulation. This could be desirable if user is already doing templating or applying middleware that changes the body content. However this fix might break any existing users' tests if they check content length value as it is.
There is an issue with interpreting "special characters" in the response body when exporting/importing simulations when the
Content-Length
header is present. I have observed that this won't occur when I manually remove theContent-Length
field from the simulation file.This can be demonstrated with a simple request to Google:
simulation_google.json
Now, the warning itself isn't so much of a problem seemingly (it's just a warning, and a valid one) but curl fails on that endpoint thereafter in simulation mode:
I spoke to @tommysitu on Glitter regarding this and he requested that I create an issue to explore this further. His comments regarding the problem:
Is this something that hoverfly should handle and/or is there something I should do here to handle these cases in a better way than just removing the
Content-Length
header for simulations where I encounter this problem?The text was updated successfully, but these errors were encountered: