Line-seq忽略字符串中的\ n

时间:2013-07-23 09:30:50

标签: clojure ring liberator

我遇到了liberator body-as-string函数和line-seq。

的问题
(println
    (line-seq
        (BufferedReader. (StringReader. (body-as-string ctx)))
    )
)

使用此curl命令,函数返回(h1,h2\nh3,h4\nh5,h6)而不是(h1,h2 h3,h4 h5,h6)

curl "localhost:3000/log" -X POST -H "Content-type:text/csv" -d "h1,h2\nh3,h4\nh5,h6"

编辑:

我添加了body-as-string函数:

(defn body-as-string
"Parcours le contexte de la requête pour en extraire le body"
[ctx]

    (timbre/debug "body-as-string")

    (if-let
        [body (get-in ctx [:request :body])]
        (condp instance? body
            java.lang.String body
            (slurp (io/reader body))
        )
    )

)

可能是编码问题?

谢谢!

1 个答案:

答案 0 :(得分:2)

您的shell可能实际上并未发送换行符,请查看此问题(及其答案):How to send line break with curl?