Skip to content

hiccup.core/html returns a RawString, which must be adapted to be a Ring response [0.2.21] #33

@hlship

Description

@hlship

Just started using huff. Problem: my Ring stack blew up because of the RawString instance returned by huff2.core/html.

I added this middleware:


(defn expand-raw-string-body
  [f]
  (fn [request]
    (let [response (f request)]
      (if (-> response :body huff/raw-string?)
        (update response :body str)
        response))))

This should be documented.

This might be an issue with http-kit rather than Ring itself:

java.lang.RuntimeException: class huff2.core.RawString is not understandable
	at org.httpkit.HttpUtils.bodyBuffer(HttpUtils.java:125)
	at org.httpkit.HttpUtils.HttpEncode(HttpUtils.java:451)
	at org.httpkit.server.HttpHandler.handleResponse(RingHandler.java:188)
	at org.httpkit.server.HttpHandler.runSync(RingHandler.java:144)
	at org.httpkit.server.HttpHandler.run(RingHandler.java:138)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:328)
	at java.base/java.lang.VirtualThread.run(VirtualThread.java:466)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions