Skip to content

Commit

Permalink
Insert Content-Length at the end of header list.
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy committed Sep 7, 2008
1 parent ca8dbda commit feef6bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion http-twiddle.el
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ length."
(insert "\r"))))

(defun http-twiddle-expand-content-length ()
"Replace any occurences of $Content-Length with the actual Content-Length."
"Replace any occurences of $Content-Length with the actual Content-Length. Insert one if needed."
(save-excursion
(goto-char (point-min))
(let ((content-length
(save-excursion (when (search-forward "\r\n\r\n" nil t)
(- (point-max) (point))))))
(save-excursion
(goto-char (- (point-max) content-length 2))
(insert "Content-Length: $Content-Length\r\n"))

(unless (null content-length)
(let ((case-fold-search t))
(while (search-forward "$content-length" nil t)
Expand Down

0 comments on commit feef6bc

Please sign in to comment.