For POP3-GET return two values (headers and list of body lines)

instead of dumping the message to (current-output-port).
This commit is contained in:
sperber 2003-01-20 16:52:25 +00:00
parent bdb1cc6b27
commit 1ee07495ba
1 changed files with 11 additions and 12 deletions

View File

@ -159,14 +159,14 @@
(values (string->number (match:substring match 1))
(string->number (match:substring match 2)))))
;; dump the message number MSGID to (current-output-port)
;;: connection x integer -> status
(define (pop3-get connection msgid)
(pop3-check-transaction-state connection pop3-get)
(let ((status (pop3-send-command connection
(build-command "RETR" (number->string msgid)))))
(pop3-dump (socket:inport (pop3-connection-command-socket connection)))
status))
(let* ((status (pop3-send-command connection
(build-command "RETR" (number->string msgid))))
(port (socket:inport (pop3-connection-command-socket connection)))
(headers (read-rfc822-headers port read-crlf-line))
(body (multiline-response->lines port)))
(values headers body)))
(define (pop3-headers connection msgid)
(pop3-check-transaction-state connection pop3-headers)
@ -263,17 +263,16 @@
(pop3-log connection (string-append "<- " command))
(pop3-handle-response (pop3-read-response connection) command)))
(define (pop3-dump fd)
(let loop ()
(let ((line (read-crlf-line fd)))
(define (multiline-response->lines port)
(let loop ((reverse-lines '()))
(let ((line (read-crlf-line port)))
(if (and (not (eof-object? line))
(not (string=? line ".")))
(let ((line (if (string-prefix? ".." line)
(substring line 1 (string-length line))
line)))
(write-string line)
(newline)
(loop))))))
(loop (cons line reverse-lines)))
(reverse reverse-lines)))))
(define (exhaust-multiline-response port)
(let loop ()