-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable to set coding system for encoding/decoding #85
Conversation
Non-ascii strings in JSON data would be unicoded when POSTing curl with JSON data because buffer-file-coding-system in data buffer is 'binary. But to change this code is not good for web page whose encoding is other encoding, so set encode in variable request-conding-system. (seq request-conding-system 'utf-8)
Duplicate: #79 But we should not use hard-coding, so I created variables. |
|
It's a just typo. Sorry.
I am not sure why emacs-request uses binary encoding. I want to use utf-8 as default.
We should use emacs-request like |
I don’t understand what you mean. Also, can you explain more why this PR is needed? |
Sorry, I didn't understand what you mean. (request
"http://httpbin.org/post"
:type "POST"
:files `(("current buffer" . ,(current-buffer))
("data" . ("data.csv" :data "1,2,3\n4,5,6\n")))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "I sent: %S" (assoc-default 'files data))))) Do you mean adding keyword argument like this? (request
"http://httpbin.org/post"
:type "POST"
:encoding 'utf-8
:files `(("current buffer" . ,(current-buffer))
("data" . ("data.csv" :data "1,2,3\n4,5,6\n")))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "I sent: %S" (assoc-default 'files data))))) |
A simpler option would be to just change 'binary to 'utf-8, as @DamienCassou did in DamienCassou#3 . What do you think? |
Yes, I think that would be good. @titaniumbones That is probably also a good idea, although it may merit some testing before pushing to |
README.rst
Outdated
|
||
.. code:: emacs-lisp | ||
|
||
(setq request-conding-system 'utf-8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it's consistent everywhere.
Still shouldn't it be coding
instead of conding
?
(setq request-conding-system 'utf-8) | |
(setq request-coding-system 'utf-8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fix this.
I have rebased this branch off of current master and added two commits here: https://github.com/tkf/emacs-request/tree/data-coding-system . The new commits:
I haven't done my own tests but when tested on travis they seem to work @shigemk2 I have submitted a PR from my new branch to your branch 😄 . that is a little convoluted but I thought it was one way for you to test my code, perhaps. |
@titaniumbones Please consider |
cf #85 (comment) for rationale.
@alphapapa done in fa58c18 , except for the docstring; I'd welcome a fix there as I am not quite sure what to say and am very sleepy 😄 . As for merging: what would you suggest we do before committing o master? This is the first substantive bug fix in quite a while, it would be nice to push it out so package maintainers can stop monkeypatching/making ad-hoc fixes. But OTOH i don't want to break people's workarounds. |
For the docstring, I would suggest changing the line in question to:
Well, it's a bit of a pain, but it seemed to work well for us when making changes to Outshine: I suggest posting a message to /r/emacs (and maybe emacs-devel), explaining what's going on, and asking package developers to test their packages with whatever branch you push this to. Then wait 4-6 weeks, and if no one reports a problem, merge to |
cf #85 (comment) for rationale.
OK, I've created a new branch "development" https://github.com/tkf/emacs-request/commits/development that includes these changes. And we can target that branch for future merges as well. The goal will maybe be to post that info to a broader audience at hte end of next week. |
@titaniumbones |
OK, these change shave been merged into the development branch (and actually superseded in part by 081f6bf and 9e3ef2d). So I'll close this PR and perhaps merge after following the strategy suggested by @alphapapa in #85 (comment) |
1 similar comment
OK, these change shave been merged into the development branch (and actually superseded in part by 081f6bf and 9e3ef2d). So I'll close this PR and perhaps merge after following the strategy suggested by @alphapapa in #85 (comment) |
@titaniumbones thank you very much! Work fine! You made my day. :) 👍 |
README.rst is and remains the README of record. Clean up discussion from tkf#85 at the risk of oversimplifying. Restore the cookie test at the risk of flapping.
cf tkf#85 (comment) for rationale.
README.rst is and remains the README of record. Clean up discussion from tkf#85 at the risk of oversimplifying. Restore the cookie test at the risk of flapping.
cf tkf#85 (comment) for rationale.
README.rst is and remains the README of record. Clean up discussion from tkf#85 at the risk of oversimplifying. Restore the cookie test at the risk of flapping.
cf tkf#85 (comment) for rationale.
README.rst is and remains the README of record. Clean up discussion from tkf#85 at the risk of oversimplifying. Restore the cookie test at the risk of flapping.
For posterity, changing the default encoding from binary to utf-8 was probably ill-advised. Neither is inherently more correct than the other, but the fact that the package defaulted to binary at inception (and remained so for years) makes it more correct. |
Commit 1562f9c seems to conflate the desire to encode request data in utf8 with also decoding server output. In light of tkf#157 and tkf#158, I am removing utf-8 decoding altogether. The impetus to encode to utf-8 in tkf#77, tkf#85, and github/org-trello/#340 suggest nothing about also decoding in utf-8, so I am crossing my fingers I won't rebreak for them. Also, clean up logging. It was impossible to follow with all the capital letters.
Non-ascii strings in JSON data would be unicoded when POSTing curl with JSON data because
buffer-file-coding-system in data buffer is 'binary.
But to change this code is not good for web page whose encoding is other encoding, so
set encode in variable request-conding-system.
Example: