Fork me on GitHub
#babashka
<
2020-04-02
>
borkdude08:04:13

There is a PR for babashka.curl to add parsing of the entire response, including headers and status code: https://github.com/borkdude/babashka.curl/pull/6 If you have any feedback, post in the issue.

$ ./bb '(clojure.pprint/pprint (dissoc (curl/get "" {:response true}) :body))'
{:status 200,
 :headers {"x-cache" "Hit from cloudfront",
           "server" "AmazonS3",
           "age" "50",
           "via" "1.1  (CloudFront)",
           "content-type" "text/html",
           "content-length" "20429",
           "x-amz-cf-pop" "AMS54-C1",
           "etag" "\"e070cc30536e64dbcabd50ca90ca5a03\"",
           "date" "Thu, 02 Apr 2020 08:51:25 GMT",
           "vary" "Accept-Encoding",
           "last-modified" "Fri, 27 Mar 2020 15:25:37 GMT",
           "x-amz-cf-id" "E5NuYdf_gOHJ_vipMfGkq6ujdPxt8apExLOpvbbMC5KodCcD39ILDA=="}}

shem09:04:20

that would be seriously handy

sogaiu09:04:00

the map representation seems nice -- but it looks like a deprecated function is being used to achieve it?

borkdude09:04:09

yeah, I wonder why

borkdude09:04:20

I tried doing it with BufferedReader, but then the body becomes empty

Mno09:04:09

it might not be related but it seems similar to the issue I had with ring middleware a long time ago where the one of the middlewares would consume the body upon reading it and the subsequent ones would assume it was empty

borkdude09:04:54

yeah, something like that

chrisblom09:04:46

Is there an easy way to eval clojure code with babashka in Emacs?

chrisblom09:04:13

I often use emacs lisp in the emacs scratch buffer for some quick calculations

chrisblom09:04:42

But I would prefer to use clojure for this, preferably without starting a repl first

sogaiu09:04:48

inf-clojure or M-x shell?

chrisblom09:04:11

ah yeah, inf-clojure might work, i'll try that

sogaiu09:04:30

monroe may work too since there is now nrepl support -- oops sorry, not released yet ๐Ÿ˜…

borkdude10:04:14

@chrisblom Please check out the nrepl-server branch. It's under active development.

$ BABASHKA_DEV=true clojure -A:main --nrepl-server 1667

borkdude10:04:22

@chrisblom inf-clojure is documented in the README

borkdude10:04:21

Autocomplete almost working....

borkdude10:04:13

@chrisblom if you want to try it out, new binary links are published in #babashka_circleci_builds

chrisblom10:04:50

cool, i'll try it, inf-clojure does not show the eval result inline, like cider does

chrisblom10:04:34

ok, it works

borkdude10:04:38

there may be some rough edges, you can report them in the github issue if you want (https://github.com/borkdude/babashka/issues/301)

chrisblom10:04:12

The --nrepl-server option is not in the help yet: https://github.com/borkdude/babashka/pull/322

chrisblom10:04:49

cool, i'll let you know if I run into issues

borkdude19:04:45

on master, babashka.curl now can return a map with :body, :headers and :status:

$ bb '(-> (curl/get "" {:response true}) :headers  (get "content-length"))'
"20429"

borkdude20:04:40

thanks a lot @rymndhng!

rymndhng20:04:08

no problem ๐Ÿ™‚ pleasure's all mind... I learned a lot about InputStream & Reader as part of the process haha

deep-symmetry21:04:51

I had a random thought today and would like to bounce it here to see if it lands on the silly floor or sticks to the wall of interestโ€ฆ When sci is configured with the :termination-safe preset, you canโ€™t use dotimes because that delegates to the forbidden loop. I was thinking of supplying an alternate implementation that instead delegates to doseq combined with range.

borkdude21:04:19

we had a similar issue with for which also uses loop, I think we just have to fix dotimes in a similar fashion. feel free to post an issue and if you want also a PR. maybe you can find in the history how we fixed this (check the history for the for macro .cljc file)

deep-symmetry21:04:08

Ok, cool, Iโ€™ll post the issue, and see if I have time to propose a PR. So many projects, so little time! ๐Ÿ˜„

deep-symmetry12:04:20

That was fast! And settles the PR question. ๐Ÿ˜† Thanks!