silkimen / cordova-plugin-advanced-http

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
400 stars 321 forks source link

[Browser] Fixing error propagation in setHeaders #444

Closed alexander-gruenewald closed 2 years ago

alexander-gruenewald commented 3 years ago

If the headers contain certain special characters (€, “, ≠, ∑, †, Ω etc..), calling the setHeaders method will throw an "Value is not a valid ByteString" error which unfortunately is neither propagated to the caller of the http-plugin, nor is the xhr request cancelled in this case.

By wrapping the setHeader-call into a try/catch, and fail the xhr request in case of an error, we'd make sure the caller of the http-plugin will receive a proper error and the xhr request gets canceled.