Skip to content

Commit

Permalink
`twittering-make-http-request' adds "Content-Length" if necessary.
Browse files Browse the repository at this point in the history
* twittering-mode.el: `twittering-make-http-request' automatically
adds the header field "Content-Length" if necessary.
(twittering-make-http-request): add the header field
"Content-Length" if it is missing on "POST" method.
(twittering-http-application-headers): do not add the header field
"Content-Length".
  • Loading branch information
cvmat committed Sep 26, 2010
1 parent 933cb30 commit bd5274b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Expand Up @@ -47,6 +47,13 @@
`twittering-make-http-request'.
(twittering-make-http-request): fix docstring.

* twittering-mode.el: `twittering-make-http-request' automatically
adds the header field "Content-Length" if necessary.
(twittering-make-http-request): add the header field
"Content-Length" if it is missing on "POST" method.
(twittering-http-application-headers): do not add the header field
"Content-Length".

2010-09-19 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el: Fix `twittering-push-uri-onto-kill-ring'.
Expand Down
10 changes: 6 additions & 4 deletions twittering-mode.el
Expand Up @@ -4194,8 +4194,8 @@ Return nil if no connection methods are available with a compromise."
"Returns an alist specifying a HTTP request.
METHOD specifies HTTP method. It must be \"GET\" or \"POST\".
HEADER-LIST is a list of (field-name . field-value) specifying HTTP header
fields. The fields \"Host\" and \"User-Agent\" are automatically filled
if necessary.
fields. The fields \"Host\", \"User-Agent\" and \"Content-Length\" are
automatically filled if necessary.
HOST specifies the host.
PORT specifies the port. This must be an integer.
PATH specifies the absolute path in URI (without query string).
Expand Down Expand Up @@ -4241,7 +4241,10 @@ The result alist includes the following keys, where a key is a symbol.
(when query-string
(concat "?" query-string))))
(header-list
`(,@(unless (assoc "Host" header-list)
`(,@(when (and (string= method "POST")
(not (assoc "Content-Length" header-list)))
`(("Content-Length" . ,(format "%d" (length post-body)))))
,@(unless (assoc "Host" header-list)
`(("Host" . ,host)))
,@(unless (assoc "User-Agent" header-list)
`(("User-Agent" . ,(twittering-user-agent))))
Expand Down Expand Up @@ -4544,7 +4547,6 @@ A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
(push (cons "Accept-Charset" "utf-8;q=0.7,*;q=0.7")
headers))
(when (string= "POST" method)
(push (cons "Content-Length" "0") headers)
(push (cons "Content-Type" "text/plain") headers))
(when twittering-proxy-use
(let* ((scheme (if twittering-use-ssl "https" "http"))
Expand Down

0 comments on commit bd5274b

Please sign in to comment.