Skip to content

Commit

Permalink
Omit a successful HTTP response and headers sent from a proxy.
Browse files Browse the repository at this point in the history
* twittering-mode.el: Omit a successful HTTP response and headers
if they seem to be sent from a proxy for CONNECT method.
(twittering-http-default-sentinel): omit a successful HTTP
response and headers from a proxy if using SSL via the proxy.
(twittering-get-response-header): do not remove headers from a
proxy.
  • Loading branch information
cvmat committed May 22, 2010
1 parent bbee457 commit ab59072
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Expand Up @@ -6,6 +6,13 @@
`utf-8-unix' for reading data retrieved from Twitter.
(twittering-start-http-session-native): likewise.

* twittering-mode.el: Omit a successful HTTP response and headers
if they seem to be sent from a proxy for CONNECT method.
(twittering-http-default-sentinel): omit a successful HTTP
response and headers from a proxy if using SSL via the proxy.
(twittering-get-response-header): do not remove headers from a
proxy.

2010-05-20 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el: The configuration of a proxy is referred via
Expand Down
23 changes: 19 additions & 4 deletions twittering-mode.el
Expand Up @@ -3203,6 +3203,25 @@ Available keywords:
(let ((temp-buffer (process-buffer proc))
(status (process-status proc))
(mes nil))
(when (and twittering-proxy-use twittering-use-ssl
(buffer-live-p temp-buffer))
;; When using SSL via a proxy with CONNECT method,
;; omit a successful HTTP response and headers if they seem to be
;; sent from the proxy.
(with-current-buffer temp-buffer
(save-excursion
(goto-char (point-min))
(let ((first-regexp
;; successful HTTP response
"\\`HTTP/1\.[01] 2[0-9][0-9] .*?\r?\n")
(next-regexp
;; following HTTP response
"^\\(\r?\n\\)HTTP/1\.[01] [0-9][0-9][0-9] .*?\r?\n"))
(when (and (search-forward-regexp first-regexp nil t)
(search-forward-regexp next-regexp nil t))
(let ((beg (point-min))
(end (match-end 1)))
(delete-region beg end)))))))
(cond
((null status)
(setq mes "Failure: no such process exists."))
Expand Down Expand Up @@ -3338,10 +3357,6 @@ BUFFER may be a buffer or the name of an existing buffer which contains the HTTP
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
;; FIXME: curl prints HTTP proxy response header, so strip it
(when (search-forward-regexp
"HTTP/1\\.[01] 200 Connection established\r\n\r\n" nil t)
(delete-region (point-min) (point)))
(if (search-forward-regexp "\r?\n\r?\n" nil t)
(buffer-substring (point-min) (match-end 0))
nil))))
Expand Down

0 comments on commit ab59072

Please sign in to comment.