how to send SSL certificate in POST request?

2017-02-21 Thread Pierre Masci
Hi, I am new to Clojure and using clj-http for the first time, to implement 
a REST client.
I don't find anywhere how to indicate where my SSL certificate is located.
Here is what I did:

(ns my-client.core
  (:require [clj-http.client :as client]
[clojure.pprint :refer :all]))

(def my-appkey "...")

(defn login [username password appkey]
  (client/post "https://.../api/certlogin;
   {:headers {"X-Application" appkey
  "Content-Type" 
"application/x-www-form-urlencoded"}
:form-params {"username" username "password" password}}))

(defn -main []
  (pprint (login "..." "..." my-appkey)))


This sends me back a response which indicates that I need to send the SSL 
certificate.
When I send the same request with curl and indicate the certificates, it 
works. This is the successful curl request:

curl -q -k --cert client-2048.crt --key client-2048.key 
https://.../api/certlogin 
-d "username=...=..." -H "X-Application: ..."
 


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?

2014-07-21 Thread Pierre Masci
Hi, I'm learning about tools to help me debug from the REPL, and I found 
these two with the same name:

clojure.stacktrace/root-cause

clojure.repl/root-cause

For a very simple case (wrong arity), they give pretty similar output:

user= (char 0 0 0)
CompilerException clojure.lang.ArityException: Wrong number of args (3) 
passed to: core/char--inliner, 
compiling:(/tmp/form-init6819528724684564936.clj:1:1) 

user= (clojure.stacktrace/root-cause *e)
#ArityException clojure.lang.ArityException: Wrong number of args (3) 
passed to: core/char--inliner

user= (clojure.repl/root-cause *e)
#CompilerException clojure.lang.ArityException: Wrong number of args 
(3) passed to: core/char--inliner, 
compiling:(/tmp/form-init6819528724684564936.clj:1:1)


I looked at the source code and they look fairly similar, but I didn't 
understand the exact details.

If they do the same job, then which one does it best?

If they perform different roles, then could you describe the difference to 
a user who doesn't need to understand the internals? ( I'm happy to 
understand them if you are willing to explain, though :) )

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?

2014-07-21 Thread Pierre Masci
I have now noticed that these two are also very similar:

clojure.stacktrace/print-stack-trace

clojure.repl/pst; (for Print Stack Trace)

Here is their output for the same error:

user= (char 0 0 0)
CompilerException clojure.lang.ArityException: Wrong number of args (3) 
passed to: core/char--inliner, 
compiling:(/tmp/form-init9068522213039312274.clj:1:1) 

user= (clojure.stacktrace/print-stack-trace *e)
clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong 
number of args (3) passed to: core/char--inliner, 
compiling:(/tmp/form-init9068522213039312274.clj:1:1)
 at clojure.lang.Compiler.analyzeSeq (Compiler.java:6651)
clojure.lang.Compiler.analyze (Compiler.java:6445)
clojure.lang.Compiler.analyze (Compiler.java:6406)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782)
clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217)
clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846)
clojure.lang.Compiler.analyzeSeq (Compiler.java:6642)
clojure.lang.Compiler.analyze (Compiler.java:6445)
clojure.lang.Compiler.eval (Compiler.java:6700)
clojure.lang.Compiler.eval (Compiler.java:)
clojure.core$eval.invoke (core.clj:2927)
clojure.main$repl$read_eval_print__6625$fn__6628.invoke (main.clj:239)
clojure.main$repl$read_eval_print__6625.invoke (main.clj:239)
clojure.main$repl$fn__6634.invoke (main.clj:257)
clojure.main$repl.doInvoke (main.clj:257)
clojure.lang.RestFn.invoke (RestFn.java:1096)

clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__591.invoke 
(interruptible_eval.clj:56)
clojure.lang.AFn.applyToHelper (AFn.java:152)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invoke (core.clj:624)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1862)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke 
(interruptible_eval.clj:41)

clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__632$fn__635.invoke
 
(interruptible_eval.clj:171)
clojure.core$comp$fn__4192.invoke (core.clj:2402)

clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__625.invoke 
(interruptible_eval.clj:138)
clojure.lang.AFn.run (AFn.java:22)
java.util.concurrent.ThreadPoolExecutor.runWorker 
(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run 
(ThreadPoolExecutor.java:615)
java.lang.Thread.run (Thread.java:744)
nil
user= (clojure.repl/pst *e)
CompilerException clojure.lang.ArityException: Wrong number of args (3) 
passed to: core/char--inliner, 
compiling:(/tmp/form-init9068522213039312274.clj:1:1)
clojure.lang.Compiler.analyzeSeq (Compiler.java:6651)
clojure.lang.Compiler.analyze (Compiler.java:6445)
clojure.lang.Compiler.analyze (Compiler.java:6406)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782)
clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217)
clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846)
clojure.lang.Compiler.analyzeSeq (Compiler.java:6642)
clojure.lang.Compiler.analyze (Compiler.java:6445)
clojure.lang.Compiler.eval (Compiler.java:6700)
clojure.lang.Compiler.eval (Compiler.java:)
clojure.core/eval (core.clj:2927)
clojure.main/repl/read-eval-print--6625/fn--6628 (main.clj:239)
Caused by:
ArityException Wrong number of args (3) passed to: core/char--inliner
clojure.lang.Compiler.analyzeSeq (Compiler.java:6639)
clojure.lang.Compiler.analyze (Compiler.java:6445)
clojure.lang.Compiler.analyze (Compiler.java:6406)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782)
clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217)
clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846)
nil

The top part of their output is the same, but not the bottom.
If no-one comes up with an explanation, I'll use both until I understand 
which one is more useful to me, and report back here if I remember 
(hopefully!)


On Monday, 21 July 2014 12:30:17 UTC+1, Pierre Masci wrote:

 Hi, I'm learning about tools to help me debug from the REPL, and I found 
 these two with the same name:

 clojure.stacktrace/root-cause

 clojure.repl/root-cause

 For a very simple case (wrong arity), they give pretty similar output:

 user= (char 0 0 0)
 CompilerException clojure.lang.ArityException: Wrong number of args 
 (3) passed to: core/char--inliner, 
 compiling:(/tmp/form-init6819528724684564936.clj:1:1) 

 user= (clojure.stacktrace/root-cause *e)
 #ArityException clojure.lang.ArityException: Wrong number of args (3) 
 passed to: core/char--inliner

 user= (clojure.repl/root-cause *e)
 #CompilerException clojure.lang.ArityException: Wrong number of args 
 (3) passed to: core/char--inliner, 
 compiling:(/tmp/form-init6819528724684564936.clj:1:1)


 I looked

A few String functions we could implement in Clojure?

2014-07-19 Thread Pierre Masci
Hi all, just nit picking about Clojure's String API.

I've been comparing it with Java's 
http://www.tutorialspoint.com/java/java_strings.htm, and I noticed that 
(not surprisingly) they are very similar.
There are just 2-3 functions that exist in Java but don't have an 
equivalent in Clojure. I was wondering if they could be worth adding to 
clojure.string :

(.indexOf s c)   and   (.lastIndexOf c)

(.startsWith s danc)   and   (.endsWith s ing)

(.charAt s 5)
same as (get s 5) but expresses a clearer intent. It's less general 
than (get) though as it only applies to Strings, so that might be 
unnecessary sugar.




.indexOf and .lastIndexOf are indicated in the Clojure Cheatsheet 
http://clojure.org/cheatsheet, maybe .startsWith and .endsWith also 
deserve to be mentioned there?

I've been wondering why some functions have been ported, like (lower-case) 
for (.toLowerCase), but not the ones mentioned above.

I told you it was nit picking (^c^) Clojure's API is awesome as it is.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use functions from clojure.contrib?

2014-07-13 Thread Pierre Masci
Haha, I've randomly come accross this exact same function in 
Prismatic/plumbing https://github.com/Prismatic/plumbing, plus a bunch of 
other interesting ones.
I'll use that version from now.


On Wednesday, 9 July 2014 13:26:21 UTC+1, Pierre Masci wrote:

 Thank you Andy, that's exactly the answer I needed.
 I thought I might be missing the right place where to look, because I'm 
 new to the ecosystem.
 http://crossclj.info 
 http://www.google.com/url?q=http%3A%2F%2Fcrossclj.infosa=Dsntz=1usg=AFQjCNG-DyQUTVfpaTQKl0M8glmTtO-tMQ
  is 
 a very good resource to know of.

 I will copy-paste that function for now.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use functions from clojure.contrib?

2014-07-09 Thread Pierre Masci
Hi, I am new to Clojure (about a week) so I might be missing something.

I want to use the (positions) 
http://clojuredocs.org/clojure_contrib/clojure.contrib.seq/positions function 
from clojure.contrib.seq.
I could simply copy its source, but I would prefer a more generic way of 
using functions form clojure.contrib.
This page http://clojure.github.io/clojure-contrib/ indicates that 
clojure.contrib is deprecated, but I could not find (positions) anywhere 
else.

What is a good solution to this problem?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use functions from clojure.contrib?

2014-07-09 Thread Pierre Masci
Thank you Andy, that's exactly the answer I needed.
I thought I might be missing the right place where to look, because I'm 
new to the ecosystem.
http://crossclj.info 
http://www.google.com/url?q=http%3A%2F%2Fcrossclj.infosa=Dsntz=1usg=AFQjCNG-DyQUTVfpaTQKl0M8glmTtO-tMQ
 is 
a very good resource to know of.

I will copy-paste that function for now.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.