Comments (10)
Thank you. Released: https://github.com/borkdude/babashka/releases/tag/v0.0.86
from babashka.curl.
@lukaszkorecki Maybe parsing headers via a temporary file isn't the best idea ever. This was done because when parsing the headers from the same stream as the response with the --include
option, there is no reliable way to detect when the headers end and the response body starts.
Could it be that we have to call .destroy
on the curl process to free up these resources?
from babashka.curl.
I can reproduce the problem locally with this script:
(require '[babashka.curl :as curl])
(while true
(Thread/sleep 1000)
(let [resp (curl/get "https://www.clojure.org")]
(:body resp)
(.destroy (:process resp))) ;; this is not helping
)
Note that this script doesn't exhibit the problem:
(while true
(Thread/sleep 1000)
(let [f (java.io.File/createTempFile "babashka.curl" ".headers")]
(spit f "foo")
(.delete f)))
from babashka.curl.
Yeah, the process included in the response map was my first hint - and I did try the .destroy
method on it and it didn't help. I wonder if it needs to be called before deleting the tempfile?
from babashka.curl.
@lukaszkorecki I'll do some testing...
Meanwhile you can poll your endpoint using something like this:
(clojure.java.shell/sh "curl" "https://www.clojure.org")))
or use HttpURLConnection
as follows:
The library https://github.com/borkdude/clj-http-lite is based around HttpURLConnection
and this library can also be used with babashka.
from babashka.curl.
So far I've found that running with the JVM (instead of GraalVM) has the same behavior so at least it's not a GraalVM problem.
from babashka.curl.
@lukaszkorecki Found the culprit!
(defn- read-headers [^File header-file]
(line-seq (io/reader header-file)))
This leaves the file handle open. Will fix ASAP.
from babashka.curl.
@borkdude oh, nice! Thank you 🎉
from babashka.curl.
@lukaszkorecki Will publish a new version of bb. Thanks for finding this.
from babashka.curl.
@borkdude Thank you for creating BB - finally it feels like we have a viable Clojure for small tasks :-)
from babashka.curl.
Related Issues (20)
- curl can print multiple headers after HTTP 100 Continue
- Use -D <tempfile> to write headers to tempfile and parse them from there, instead of stdout
- Capture standard error from curl shell command HOT 8
- Add documentation for data-raw HOT 5
- form-params are sent as multipart/form-data HOT 2
- Support :multipart HOT 7
- Support (S)FTP
- Pass --compressed by default.
- Segmentation fault when reading /etc/passwd HOT 23
- Add to clojars HOT 6
- Unable to send post req or debug HOT 25
- Is there a way to display curl progress information? HOT 1
- As well as --data-raw, add --data-binary HOT 8
- Bundled curl with Windows 10 doesn't support `--compressed` HOT 4
- Cannot retry when using `:as :stream` option HOT 13
- Make redirect (--location) optional
- Last set-cookie headers on a page overwrites the ones before HOT 11
- Set up CI HOT 1
- BREAKING: Always parse response headers and return map
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babashka.curl.