tkf / emacs-request

Request.el -- Easy HTTP request for Emacs Lisp
http://tkf.github.com/emacs-request/
GNU General Public License v3.0
629 stars 93 forks source link

Add fix for an edge case (with a test) involving "100 Continue" and long body #157

Closed dvzubarev closed 5 years ago

dvzubarev commented 5 years ago

Emacs 26.3, Ubuntu 18.04.1

Without that fix, Emacs interprets curl output as utf-8-dos and strips all \r . It results in an error (search-failed "^\r\n"), when moving from "100 Continue" to the next one in request--goto-next-body.

It's kind of strange behavior of Emacs, since there is a single newline after the body:

body\n
(:num-redirects 0 :url-effective "http://127.0.0.1:60079/longtextline")

From the docs:

Emacs recognizes which kind of end-of-line conversion to use based on the contents of the file: if it sees only carriage returns, or only carriage return followed by linefeed sequences, then it chooses the end-of-line conversion accordingly.

This behavior only manifests itself when body is a single long line.

Alternative solutions: Use inhibit-eol-conversion somehow. Change (set-process-coding-system proc encoding encoding) to (set-process-coding-system proc 'no-conversion 'no-conversion) in request--curl.

For reference I stumbled on this bug, while using ycmd (company-ycmd). Original error was

REQUEST [error] Error (error) while connecting to http://127.0.0.1:34353/completions.
deferred error : (wrong-type-argument number-or-marker-p nil)
dickmao commented 5 years ago

Thank you for your thoughtful and well-researched PR.