|
485 | 485 | (defn- print-debug! |
486 | 486 | "Print out debugging information to *out* for a given request." |
487 | 487 | [{:keys [debug-body body] :as req} http-req] |
488 | | - (println "Request:" (type body)) |
489 | | - (clojure.pprint/pprint |
490 | | - (assoc req |
491 | | - :body (if (opt req :debug-body) |
492 | | - (cond |
493 | | - (isa? (type body) String) |
494 | | - body |
495 | | - |
496 | | - (isa? (type body) HttpEntity) |
497 | | - (let [baos (ByteArrayOutputStream.)] |
498 | | - (.writeTo ^HttpEntity body baos) |
499 | | - (.toString baos "UTF-8")) |
500 | | - |
501 | | - :else nil) |
502 | | - (if (isa? (type body) String) |
503 | | - (format "... %s bytes ..." |
504 | | - (count body)) |
505 | | - (and body (bean body)))) |
506 | | - :body-type (type body))) |
507 | | - (println "HttpRequest:") |
508 | | - (clojure.pprint/pprint (bean http-req))) |
| 488 | + (println |
| 489 | + (with-out-str |
| 490 | + (println "Request:" (type body)) |
| 491 | + (clojure.pprint/pprint |
| 492 | + (assoc req |
| 493 | + :body (if (opt req :debug-body) |
| 494 | + (cond |
| 495 | + (isa? (type body) String) |
| 496 | + body |
| 497 | + |
| 498 | + (isa? (type body) HttpEntity) |
| 499 | + (let [baos (ByteArrayOutputStream.)] |
| 500 | + (.writeTo ^HttpEntity body baos) |
| 501 | + (.toString baos "UTF-8")) |
| 502 | + |
| 503 | + :else nil) |
| 504 | + (if (isa? (type body) String) |
| 505 | + (format "... %s bytes ..." |
| 506 | + (count body)) |
| 507 | + (and body (bean body)))) |
| 508 | + :body-type (type body))) |
| 509 | + (println "HttpRequest:") |
| 510 | + (clojure.pprint/pprint (bean http-req))))) |
509 | 511 |
|
510 | 512 | (defn- build-response-map |
511 | 513 | [^HttpResponse response req ^HttpUriRequest http-req http-url |
|
0 commit comments