Permalink
Browse files

Avoid c.c.defvar- in r.m.cookies.

  • Loading branch information...
1 parent 9bf5f6f commit 34ef33036d3077ec15b080b5b9c2a2bf892d8202 @mmcgrana committed Nov 1, 2010
Showing with 47 additions and 31 deletions.
  1. +31 −23 ring-core/src/ring/middleware/cookies.clj
  2. +16 −8 ring-core/src/ring/middleware/session/cookie.clj
View
54 ring-core/src/ring/middleware/cookies.clj
@@ -1,32 +1,40 @@
(ns ring.middleware.cookies
"Cookie manipulation."
- (:use [clojure.contrib.def :only (defvar-)])
(:require [ring.util.codec :as codec]))
-(defvar- re-token #"[!#$%&'*\-+.0-9A-Z\^_`a-z\|~]+"
- "HTTP token: 1*<any CHAR except CTLs or tspecials>. See RFC2068")
-
-(defvar- re-quoted #"\"(\\\"|[^\"])*\""
- "HTTP quoted-string: <\"> *<any TEXT except \"> <\">. See RFC2068.")
-
-(defvar- re-value (str re-token "|" re-quoted)
- "HTTP value: token | quoted-string. See RFC2109")
-
-(defvar- re-cookie
- (re-pattern (str "\\s*(" re-token ")=(" re-value ")\\s*[;,]?"))
- "HTTP cookie-value: NAME \"=\" VALUE")
-
-(defvar- cookie-attrs
- {"$Path" :path, "$Domain" :domain, "$Port" :port}
- "Special attributes defined by RFC2109 and RFC2965 that apply to the
- Cookie header.")
-
-(defvar- set-cookie-attrs
+(def ^{:private true
+ :doc "HTTP token: 1*<any CHAR except CTLs or tspecials>. See RFC2068"}
+ re-token
+ #"[!#$%&'*\-+.0-9A-Z\^_`a-z\|~]+")
+
+(def ^{:private true
+ :doc "HTTP quoted-string: <\"> *<any TEXT except \"> <\">. See RFC2068."}
+ re-quoted
+ #"\"(\\\"|[^\"])*\"")
+
+(def ^{:private true
+ :doc "HTTP value: token | quoted-string. See RFC2109"}
+ re-value
+ (str re-token "|" re-quoted))
+
+(def ^{:private true
+ :doc "HTTP cookie-value: NAME \"=\" VALUE"}
+ re-cookie
+ (re-pattern (str "\\s*(" re-token ")=(" re-value ")\\s*[;,]?")))
+
+(def ^{:private true
+ :doc "Special attributes defined by RFC2109 and RFC2965 that apply to the
+ Cookie header."}
+ cookie-attrs
+ {"$Path" :path, "$Domain" :domain, "$Port" :port})
+
+(def ^{:private true
+ :doc "Attributes defined by RFC2109 and RFC2965 that apply to the
+ Set-Cookie header."}
+ set-cookie-attrs
{:comment "Comment", :comment-url "CommentURL", :discard "Discard",
:domain "Domain", :max-age "Max-Age", :path "Path", :port "Port",
- :secure "Secure", :version "Version", :expires "Expires"}
- "Attributes defined by RFC2109 and RFC2965 that apply to the Set-Cookie
- header.")
+ :secure "Secure", :version "Version", :expires "Expires"})
(defn- parse-cookie-header
"Turn a HTTP Cookie header into a list of name/value pairs."
View
24 ring-core/src/ring/middleware/session/cookie.clj
@@ -7,17 +7,25 @@
(javax.crypto Cipher Mac)
(javax.crypto.spec SecretKeySpec IvParameterSpec)))
-(defvar- seed-algorithm "SHA1PRNG"
- "Algorithm to seed random numbers.")
+(def ^{:private true
+ :doc "Algorithm to seed random numbers."}
+ seed-algorithm
+ "SHA1PRNG")
-(defvar- hmac-algorithm "HmacSHA256"
- "Algorithm to generate a HMAC.")
+(def ^{:private true
+ :doc "Algorithm to generate a HMAC."}
+ hmac-algorithm
+ "HmacSHA256")
-(defvar- crypt-type "AES"
- "Type of encryption to use.")
+(def ^{:private true
+ :doc "Type of encryption to use."}
+ crypt-type
+ "AES")
-(defvar- crypt-algorithm "AES/CBC/PKCS5Padding"
- "Full algorithm to encrypt data with.")
+(def ^{:private true
+ :doc "Full algorithm to encrypt data with."}
+ crypt-algorithm
+ "AES/CBC/PKCS5Padding")
(defn- secure-random-bytes
"Returns a random byte array of the specified size."

0 comments on commit 34ef330

Please sign in to comment.