alphapapa / pocket-lib.el

Emacs library for the getpocket.com API
GNU General Public License v3.0
21 stars 5 forks source link

`pocket-lib--request`: Character Encoding in HTTP Requests #5

Closed lwj786 closed 6 months ago

lwj786 commented 6 months ago

When I wanted to add or modify tags (contains Chinese characters) to the article, I encountered an error.

The main error message is as follows:

error in process filter: url-https-proxy-after-change-function: Error: (error Multibyte text in HTTP request: POST /v3/send HTTP/1.1
...

After viewing the source code and modifying the data encoding in the function pocket-lib--request, the issue seems to be resolved.

diff --git a/pocket-lib.el b/pocket-lib.el
index b5d72e6..f449b4c 100644
--- a/pocket-lib.el
+++ b/pocket-lib.el
@@ -186,7 +186,7 @@ The response body is automatically parsed with `json-read'."
     (request url
              :type "POST"
              :headers pocket-lib-default-extra-headers
-             :data data
+             :data (encode-coding-string data 'utf-8)
              :sync sync
              :parser #'json-read
              :success (cl-function
alphapapa commented 6 months ago

Hi,

Thanks, I've pushed the fix.