GlobalNOC / GRNOC-WebService

GRNOC::WebService Perl Module
Apache License 2.0
0 stars 5 forks source link

Fixing content length #17

Closed ajragusa closed 3 years ago

ajragusa commented 3 years ago

There was an issue with determining the content length of the response because the response was already encoded UTF-8 and we were then re-encoding it as UTF-8 which could potentially add additional characters (ie... length) causing a failure to be reported in the browser even though all of the content was sent. I also added a unit test to verify this functions properly.

bgeels commented 3 years ago

This look good to me. Merging in.

defc0n commented 3 years ago

I think you want to tell length to count the number of bytes, not characters, as that is what the Content-Length header should be using. https://perldoc.perl.org/bytes.html

ajragusa commented 3 years ago

Hey Mitch

Hope things are going well for you. If my understanding is correct, since the answer is already encoded as UTF-8 the number of characters = the number of bytes (at least I believe this is true).

Also adding use bytes to this module, causes the unicode test to fail as I believe it doesn’t interpret them as a value, but as individual bytes and then gets encoded as individual bytes. This was actually what I had tried first (if you look at https://github.com/GlobalNOC/GRNOC-WebService/pull/17/commits/5c01b962edd1b7759b044220fb1e7557b8f8c3db https://github.com/GlobalNOC/GRNOC-WebService/pull/17/commits/5c01b962edd1b7759b044220fb1e7557b8f8c3db you can see that was my initial fix, but it totally broke unicode support)

A.J.

On Sep 21, 2020, at 1:22 PM, Mitch McCracken notifications@github.com wrote:

I think you want to tell length to count the number of bytes, not characters, as that is what the Content-Length header should be using. https://perldoc.perl.org/bytes.html https://perldoc.perl.org/bytes.html — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GlobalNOC/GRNOC-WebService/pull/17#issuecomment-696255154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2VRNHCT7NPHF3OZIWZ7MLSG6DVJANCNFSM4RUYO6TQ.