Permalink
Browse files

Removed Apache Commons IO dependency

  • Loading branch information...
1 parent 62224e3 commit 9fb5ee7354e255d0e3aace97d3d87f1d0ff96ab4 @weavejester weavejester committed Jan 24, 2010
Showing with 14 additions and 12 deletions.
  1. +0 −1 project.clj
  2. +1 −2 src/ring/handler/dump.clj
  3. +8 −5 src/ring/middleware/file_info.clj
  4. +5 −4 src/ring/util/servlet.clj
View
1 project.clj
@@ -3,7 +3,6 @@
:url "http://github.com/mmcgrana/ring"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]
- [commons-io "1.4"]
[org.mortbay.jetty/jetty "6.1.14"]
[org.mortbay.jetty/jetty-util "6.1.14"]
[org.mortbay.jetty/servlet-api-2.5 "6.1.14"]
View
3 src/ring/handler/dump.clj
@@ -1,8 +1,7 @@
(ns ring.handler.dump
(:use (clj-html core helpers)
(clojure.contrib def)
- (clojure set))
- (:import (org.apache.commons.io IOUtils)))
+ (clojure set)))
(declare css)
View
13 src/ring/middleware/file_info.clj
@@ -1,7 +1,6 @@
(ns ring.middleware.file-info
- (:use (clojure.contrib def))
- (:import (org.apache.commons.io FilenameUtils)
- (java.io File)))
+ (:use clojure.contrib.def)
+ (:import java.io.File))
(defvar- base-mime-types
{"ai" "application/postscript"
@@ -59,12 +58,16 @@
"xwd" "image/x-xwindowdump"
"zip" "application/zip"})
+(defn- get-extension
+ "Returns the file extension of a file."
+ [file]
+ (second (re-find #"\.([^./\\]+)$" (.getPath file))))
+
(defn- guess-mime-type
"Returns a String corresponding to the guessed mime type for the given file,
or application/octet-stream if a type cannot be guessed."
[#^File file mime-types]
- (get mime-types (FilenameUtils/getExtension (.getPath file))
- "application/octet-stream"))
+ (get mime-types (get-extension file) "application/octet-stream"))
(defn wrap-file-info
"Wrap an app such that responses with a file a body will have
View
9 src/ring/util/servlet.clj
@@ -1,9 +1,10 @@
(ns ring.util.servlet
"Compatibility functions for turning a ring handler into a Java servlet."
+ (:use (clojure.contrib duck-streams except))
(:import (java.io File InputStream FileInputStream)
- (javax.servlet.http HttpServlet HttpServletRequest HttpServletResponse)
- (org.apache.commons.io IOUtils))
- (:use (clojure.contrib except)))
+ (javax.servlet.http HttpServlet
+ HttpServletRequest
+ HttpServletResponse)))
(defn- get-headers
"Creates a name/value map of all the request headers."
@@ -78,7 +79,7 @@
(instance? InputStream body)
(let [#^InputStream b body]
(with-open [out (.getOutputStream response)]
- (IOUtils/copy b out)
+ (copy b out)
(.close b)
(.flush out)))
(instance? File body)

0 comments on commit 9fb5ee7

Please sign in to comment.