Murphy McMahon
unread,Oct 4, 2012, 11:02:21 AM10/4/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to clojure...@googlegroups.com
Hello Clutch users,
For a couple of days I have been fiddling with a simple SMTP server
that would store attachments it receives in CouchDB via Clutch. (I've
used Clojure and CouchDB for a little while but am relatively new to
SMTP and the javax.mail.* lib.)
For simplicity's and memory footprint's sake, I would like to handle
and insert the multipart attachments as InputStreams, without any
intermediate file-saving.
I noticed that javax.mail.internet.MimeBodyPart instances representing
individual parts/attachments provide a different class as a result of
their .getInputStream() method, apparently depending on whether the
attachment is plain text or binary in nature
(javax.mail.util.SharedByteArrayInputStream or
com.sun.mail.util.BASE64DecoderStream, respectively). In the former
case, calls to clutch/put-attachment go off without a hitch.
In the latter case, however, the REPL just appears to freeze, and
after an extended period there is a timeout and I get the following
exception/stacktrace:
org.apache.http.NoHttpResponseException: The target server failed to respond
at org.apache.http.impl.conn.DefaultResponseParser.parseHead
(DefaultResponseParser.java:101)
org.apache.http.impl.io.AbstractMessageParser.parse
(AbstractMessageParser.java:252)
org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader
(AbstractHttpClientConnection.java:282)
org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader
(DefaultClientConnection.java:247)
org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader
(AbstractClientConnAdapter.java:216)
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse
(HttpRequestExecutor.java:298)
org.apache.http.protocol.HttpRequestExecutor.execute
(HttpRequestExecutor.java:125)
org.apache.http.impl.client.DefaultRequestDirector.tryExecute
(DefaultRequestDirector.java:647)
org.apache.http.impl.client.DefaultRequestDirector.execute
(DefaultRequestDirector.java:464)
org.apache.http.impl.client.AbstractHttpClient.execute
(AbstractHttpClient.java:820)
org.apache.http.impl.client.AbstractHttpClient.execute
(AbstractHttpClient.java:754)
org.apache.http.impl.client.AbstractHttpClient.execute
(AbstractHttpClient.java:732)
clj_http.core$request.invoke (core.clj:238)
clojure.lang.Var.invoke (Var.java:415)
clj_http.client$wrap_query_params$fn__2054.invoke (client.clj:293)
clj_http.client$wrap_basic_auth$fn__2058.invoke (client.clj:306)
clj_http.client$wrap_oauth$fn__2062.invoke (client.clj:315)
clj_http.client$wrap_user_info$fn__2067.invoke (client.clj:325)
clj_http.client$wrap_url$fn__2097.invoke (client.clj:374)
clj_http.client$wrap_redirects$fn__2001.invoke (client.clj:106)
clj_http.client$wrap_decompression$fn__2006.invoke (client.clj:142)
clj_http.client$wrap_input_coercion$fn__2023.invoke (client.clj:234)
clj_http.client$wrap_output_coercion$fn__2012.invoke (client.clj:151)
clj_http.client$wrap_exceptions$fn__1991.invoke (client.clj:80)
clj_http.client$wrap_accept$fn__2036.invoke (client.clj:261)
clj_http.client$wrap_accept_encoding$fn__2041.invoke (client.clj:272)
clj_http.client$wrap_content_type$fn__2032.invoke (client.clj:253)
clj_http.client$wrap_form_params$fn__2077.invoke (client.clj:346)
clj_http.client$wrap_nested_params$fn__2094.invoke (client.clj:366)
clj_http.client$wrap_method$fn__2072.invoke (client.clj:331)
clj_http.cookies$wrap_cookies$fn__1744.invoke (cookies.clj:116)
clj_http.links$wrap_links$fn__1777.invoke (links.clj:50)
clj_http.client$wrap_unknown_host$fn__2102.invoke (client.clj:380)
com.ashafa.clutch.http_client$connect.invoke (http_client.clj:52)
com.ashafa.clutch.http_client$couchdb_request_STAR_.doInvoke
(http_client.clj:75)
clojure.lang.RestFn.applyTo (RestFn.java:142)
clojure.core$apply.invoke (core.clj:601)
com.ashafa.clutch.http_client$couchdb_request.doInvoke (http_client.clj:80)
clojure.lang.RestFn.invoke (RestFn.java:619)
com.ashafa.clutch$put_attachment.doInvoke (clutch.clj:358)
I am going to keep trying to debug this but I just thought I would ask
here in case anyone has faced this, or worked with javax.mail.* and
Clutch, and can point me in the right direction.
Thanks,
Murph