clojureringliberator

Line-seq ignore \n in string


I have a problem with liberator body-as-string function and line-seq.

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

With this curl command the function return (h1,h2\nh3,h4\nh5,h6) instead of (h1,h2 h3,h4 h5,h6)

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

EDIT :

I add body-as-string function :

(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))
        )
    )

)

Maybe is it an encoding problem ?

Thank you !


Solution

  • Your shell is probably not actually sending a newline, check this question (and its answers): How to send line break with curl?