Some HTTP servers (like mine) do not bother to respond with 200 OK, just 200 (trailing space)
When doing a POST with spork/http like this
(defn table-to-form-encoded [data]
(string/join (map
(fn [p]
(let
[k (p 0)
v (p 1)
fmt (cond (integer? v) "d" (number? v) "g" (string? v) "s" true "m")]
(string/format (string "%s=%" fmt) k v)))
(pairs data)) "&"))
(defn make-post-request [url data]
(let [body (table-to-form-encoded data) headers {"Content-Type" "application/x-www-form-urlencoded"}]
(printf "%m" ['make-post-request headers body])
(let [response (http/request "POST" url :headers headers :body body)]
(printf "25 %m" response)
(print "Status Code: " (response :status))
(print "Response Body: " (response :body)))))
The POST is successful in that it's accepted by the server, but spork/request just throws an error .
However the RFC says that the Reason Phrase is optional. Refer StackOverflow
Please consider changing (some :printable) to (any :printable) in http.janet` :
(def- http-grammar
~{:request-status (* :method :ws :path :ws "HTTP/1." :d :any-ws :rn)
:response-status (* "HTTP/1." :d :ws (/ ':d+ ,scan-number)
:ws '(some :printable) :rn)
Some HTTP servers (like mine) do not bother to respond with
200 OK, just200(trailing space)When doing a POST with spork/http like this
The POST is successful in that it's accepted by the server, but
spork/requestjust throws anerror.However the RFC says that the Reason Phrase is optional. Refer StackOverflow
Please consider changing
(some :printable)to(any :printable) inhttp.janet` :