- (let ((method (gnus-find-method-for-group group)))
- (funcall (gnus-get-function method 'request-body)
- article (gnus-group-real-name group) (nth 1 method))))
-
-(defun gnus-request-post (method)
- "Post the current buffer using METHOD."
- (when (stringp method)
- (setq method (gnus-server-to-method method)))
- (funcall (gnus-get-function method 'request-post) (nth 1 method)))
-
-(defun gnus-request-scan (group method)
- "Request a SCAN being performed in GROUP from METHOD.
-If GROUP is nil, all groups on METHOD are scanned."
- (let ((method (if group (gnus-find-method-for-group group) method)))
- (funcall (gnus-get-function method 'request-scan)
- (and group (gnus-group-real-name group)) (nth 1 method))))
-
-(defsubst gnus-request-update-info (info method)
- "Request that METHOD update INFO."
- (when (stringp method)
- (setq method (gnus-server-to-method method)))
- (when (gnus-check-backend-function 'request-update-info (car method))
- (funcall (gnus-get-function method 'request-update-info)
+ (let* ((gnus-command-method (gnus-find-method-for-group group))
+ (head (gnus-get-function gnus-command-method 'request-body t))
+ res clean-up)
+ (cond
+ ;; Check the cache.
+ ((and gnus-use-cache
+ (numberp article)
+ (gnus-cache-request-article article group))
+ (setq res (cons group article)
+ clean-up t))
+ ;; Use `head' function.
+ ((fboundp head)
+ (setq res (funcall head article (gnus-group-real-name group)
+ (nth 1 gnus-command-method))))
+ ;; Use `article' function.
+ (t
+ (setq res (gnus-request-article article group)
+ clean-up t)))
+ (when clean-up
+ (save-excursion
+ (set-buffer nntp-server-buffer)
+ (goto-char (point-min))
+ (when (search-forward "\n\n" nil t)
+ (delete-region (point-min) (1- (point))))))
+ res))
+
+(defun gnus-request-post (gnus-command-method)
+ "Post the current buffer using GNUS-COMMAND-METHOD."
+ (when (stringp gnus-command-method)
+ (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
+ (funcall (gnus-get-function gnus-command-method 'request-post)
+ (nth 1 gnus-command-method)))
+
+(defun gnus-request-scan (group gnus-command-method)
+ "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
+If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
+ (when gnus-plugged
+ (let ((gnus-command-method
+ (if group (gnus-find-method-for-group group) gnus-command-method))
+ (gnus-inhibit-demon t))
+ (funcall (gnus-get-function gnus-command-method 'request-scan)
+ (and group (gnus-group-real-name group))
+ (nth 1 gnus-command-method)))))
+
+(defsubst gnus-request-update-info (info gnus-command-method)
+ "Request that GNUS-COMMAND-METHOD update INFO."
+ (when (stringp gnus-command-method)
+ (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
+ (when (gnus-check-backend-function
+ 'request-update-info (car gnus-command-method))
+ (funcall (gnus-get-function gnus-command-method 'request-update-info)