johanhaleby / stub-http

Client library agnostic way to stub HTTP endpoints in Clojure
MIT License
70 stars 10 forks source link

read PUT data from tmp file before it gets deleted #11

Closed opqdonut closed 4 years ago

opqdonut commented 4 years ago

NanoHTTPD shoves PUT body data into a tmp file, which it then deletes after request has been handled. This means that you'd see a path for a nonexistent file when looking at a PUT recording.

Slurp the file in session->stub-request to fix this.

See also:

johanhaleby commented 4 years ago

Thanks a lot for the PR!

johanhaleby commented 4 years ago

I've tried to make a new release but it seems like the lein-release plugin has stopped working:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at clojure.lang.RT.classForName(RT.java:2207)
    at clojure.lang.RT.classForName(RT.java:2216)
    at clojure.lang.RT.loadClassForName(RT.java:2235)
    at clojure.lang.RT.load(RT.java:453)
    at clojure.lang.RT.load(RT.java:428)
    at clojure.core$load$fn__6824.invoke(core.clj:6126)
    at clojure.core$load.invokeStatic(core.clj:6125)
    at clojure.core$load.doInvoke(core.clj:6109)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5908)
    at clojure.core$load_one.invoke(core.clj:5903)
    at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
    at clojure.core$load_lib.invokeStatic(core.clj:5947)
    at clojure.core$load_lib.doInvoke(core.clj:5928)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$load_libs.invokeStatic(core.clj:5985)
    at clojure.core$load_libs.doInvoke(core.clj:5969)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$require.invokeStatic(core.clj:6007)
    at clojure.core$require.doInvoke(core.clj:6007)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at leiningen.core.utils$require_resolve.invokeStatic(utils.clj:102)
    at leiningen.core.utils$require_resolve.invoke(utils.clj:95)
    at leiningen.core.utils$require_resolve.invokeStatic(utils.clj:105)
    at leiningen.core.utils$require_resolve.invoke(utils.clj:95)
    at leiningen.core.main$lookup_task_var.invokeStatic(main.clj:69)
    at leiningen.core.main$lookup_task_var.invoke(main.clj:65)
    at leiningen.core.main$pass_through_help_QMARK_.invokeStatic(main.clj:79)
    at leiningen.core.main$pass_through_help_QMARK_.invoke(main.clj:73)
    at leiningen.core.main$task_args.invokeStatic(main.clj:82)
    at leiningen.core.main$task_args.invoke(main.clj:81)
    at leiningen.core.main$resolve_and_apply.invokeStatic(main.clj:339)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:336)
    at leiningen.core.main$_main$fn__6681.invoke(main.clj:452)
    at leiningen.core.main$_main.invokeStatic(main.clj:442)
    at leiningen.core.main$_main.doInvoke(main.clj:439)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
Revert "Trying to add contrib dep to make lein-release work"
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.core$apply.invokeStatic(core.clj:665)
    at clojure.main$main_opt.invokeStatic(main.clj:491)
    at clojure.main$main_opt.invoke(main.clj:487)
    at clojure.main$main.invokeStatic(main.clj:598)
    at clojure.main$main.doInvoke(main.clj:561)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:37)
Caused by: Syntax error compiling at (leiningen/release.clj:1:1).
    at clojure.lang.Compiler.load(Compiler.java:7647)
    at leiningen.release$fn__8986.invokeStatic(release.clj:143)
    at leiningen.release$fn__8986.invoke(release.clj:138)
    at leiningen.release__init.load(Unknown Source)
    at leiningen.release__init.<clinit>(Unknown Source)
    ... 50 more
Caused by: java.io.FileNotFoundException: Could not locate clojure/contrib/io__init.class, clojure/contrib/io.clj or clojure/contrib/io.cljc on classpath.
    at clojure.lang.RT.load(RT.java:466)
    at clojure.lang.RT.load(RT.java:428)
    at clojure.core$load$fn__6824.invoke(core.clj:6126)
    at clojure.core$load.invokeStatic(core.clj:6125)
    at clojure.core$load.doInvoke(core.clj:6109)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5908)
    at clojure.core$load_one.invoke(core.clj:5903)
    at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
    at clojure.core$load_lib.invokeStatic(core.clj:5947)
    at clojure.core$load_lib.doInvoke(core.clj:5928)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$load_libs.invokeStatic(core.clj:5985)
    at clojure.core$load_libs.doInvoke(core.clj:5969)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$use.invokeStatic(core.clj:6093)
    at clojure.core$use.doInvoke(core.clj:6093)
    at clojure.lang.RestFn.invoke(RestFn.java:436)
    at leiningen.release$eval662$loading__6706__auto____663.invoke(jar:file:/Users/johan/.m2/repository/lein-release/lein-release/1.1.0/lein-release-1.1.0.jar!/leiningen/release.clj:1)
    at leiningen.release$eval662.invokeStatic(jar:file:/Users/johan/.m2/repository/lein-release/lein-release/1.1.0/lein-release-1.1.0.jar!/leiningen/release.clj:1)
    at leiningen.release$eval662.invoke(jar:file:/Users/johan/.m2/repository/lein-release/lein-release/1.1.0/lein-release-1.1.0.jar!/leiningen/release.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7176)
    at clojure.lang.Compiler.eval(Compiler.java:7165)
    at clojure.lang.Compiler.load(Compiler.java:7635)
    ... 54 more

Do you have any idea on how this can be resolved?

opqdonut commented 4 years ago

Sorry, I've never used lein-release... :confused:

Anyway, clojure.contrib.io is ancient stuff. It looks like lein-release is pretty ancient too, it depends on clojure 1.3.0.

It looks like these days leiningen comes with a lein deploy command: https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#publishing-libraries

johanhaleby commented 4 years ago

@opqdonut Thank for the pointer, guess I need to look into that :)

opqdonut commented 4 years ago

any luck?

johanhaleby commented 4 years ago

I actually pushed it now, but I think I accidentally overwrote the old version. Could you try?

opqdonut commented 4 years ago

I upgraded to 0.2.8 and PUT requests work now, thanks!