chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] pop3 support TOP command?


From: John J Foerch
Subject: [Chicken-hackers] pop3 support TOP command?
Date: Sat, 15 Mar 2014 16:28:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hello,

I have a need to be able to read message headers from a POP3 server
without downloading entire messages.  POP3 protocol supports this by an
optional (but widely supported) command, TOP.  Attached is a little
patch that adds support for the TOP command to the pop3 egg via a second
optional argument to pop3:open.  Let me know if you would like to see
this done any differently.

I wonder though whether it might be nicer to have a higher level POP3
api.  While researching my question about getting headers, I came across
some documentation on Racket's pop3 library[1] and it looks pretty nice.
Maybe this would be an idea for a new egg to supersede the pop3 egg.  I
would be glad to hear anybody's thoughts on this.

[1]: http://docs.racket-lang.org/net/pop3.html

-- 
John Foerch

--- a/pop3.scm  2014-03-15 16:06:24.000000000 -0400
+++ b/pop3.scm  2014-03-15 16:01:59.000000000 -0400
@@ -102,11 +102,13 @@
                (loop (cons (cons (string->number i) (string->number s)) lst)) )
               (_ (pop3-error "invalid response from LIST command" ln)) ) ) ) ) 
) )
 
-(define (pop3:open pop3 index . del)
+(define (pop3:open pop3 index . args)
   (when (pop3-open pop3)
     (pop3-error "POP3 transfer already in progress") )
-  (let ((del (optional del #f)))
-    (send pop3 "RETR ~A" index)
+  (let-optionals args ((del #f) (top #f))
+    (if top
+       (send pop3 "TOP ~A ~A" index (if (number? top) top 0))
+       (send pop3 "RETR ~A" index))
     (pop3-open-set! pop3 #t)
     (let ((ln #f)
          (closed #f)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]