Skip to content

Commit

Permalink
auto-convert multipart args to string when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
akkartik committed Jun 9, 2012
1 parent 46e3820 commit d5331ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/srv.arc
Expand Up @@ -295,7 +295,8 @@ Connection: close"))
(awhen (and headers (alref headers "name"))
(list unstring.it
(w/table multipart-arg
(= (multipart-arg "contents") body)
(= (multipart-arg "contents")
(check bytes-string.body all-ascii? body))
(each (property val) headers
(unless (iso "name" property)
(= multipart-arg.property val)))))))
Expand All @@ -322,6 +323,10 @@ Connection: close"))
l)
'string))

(def all-ascii?(l)
(and (isa l 'cons)
(errsafe:all [<= 0 _ 127] l)))

; "\"abc\"" => "abc"
(def unstring(s)
(if (iso #\" s.0)
Expand Down

0 comments on commit d5331ac

Please sign in to comment.