Fork me on GitHub
#aleph
<
2020-10-12
>
jjttjj15:10:41

Anyone know why I might be getting 400 errors with aleph's http client, when clj-http gives a 200 response for the same request? It's just a basic get request with no params

jeroenvandijk17:10:50

Could be anything I guess, missing query params, authentication. Can you share the request map?

jjttjj17:10:16

Just a basic get on a public endpoint with no params

;;clj-http works as expected:
(clj-http/get ""
  {:debug       true
   :debug-body? true
   :as :json})

@(aleph-http/get ""
   {:debug true
    :debug-body? true
    :as :json})
;;=>
{:aleph/keep-alive? true,
    :aleph/complete #object[manifold.deferred.SuccessDeferred
                            "0x7397ac1"
                            {:status :ready, :val false}],
    :headers {"server" "cloudflare",
              "content-type" "application/json; charset=utf-8",
              "content-length" "44",
              "connection" "keep-alive",
              "cf-request-id" "05bf7ff214000091da2324c200000001",
              "set-cookie" "__cfduid=d66496ec04481eff43488e02e22fcad141602524469; expires=Wed, 11-Nov-20 17:41:09 GMT; path=/; domain=.; HttpOnly; SameSite=Lax; Secure",
              "expect-ct" "max-age=604800, report-uri=\"\"",
              "cf-cache-status" "EXPIRED",
              "cf-ray" "5e129c302f8691da-EWR",
              "date" "Mon, 12 Oct 2020 17:41:09 GMT"},
    :status 400,
    :body #object[java.io.ByteArrayInputStream
                  "0x5d066dd"
                  "[email protected]"]}{:aleph/keep-alive? true,
    :aleph/complete #object[manifold.deferred.SuccessDeferred
                            "0x7397ac1"
                            {:status :ready, :val false}],
    :headers {"server" "cloudflare",
              "content-type" "application/json; charset=utf-8",
              "content-length" "44",
              "connection" "keep-alive",
              "cf-request-id" "05bf7ff214000091da2324c200000001",
              "set-cookie" "__cfduid=d66496ec04481eff43488e02e22fcad141602524469; expires=Wed, 11-Nov-20 17:41:09 GMT; path=/; domain=.; HttpOnly; SameSite=Lax; Secure",
              "expect-ct" "max-age=604800, report-uri=\"\"",
              "cf-cache-status" "EXPIRED",
              "cf-ray" "5e129c302f8691da-EWR",
              "date" "Mon, 12 Oct 2020 17:41:09 GMT"},
    :status 400,
    :body #object[java.io.ByteArrayInputStream
                  "0x5d066dd"
                  "[email protected]"]}

jjttjj17:10:27

could it be related to SSL config?

mccraigmccraig17:10:33

i suspect probably not ssl config, since you are getting an http 400 back. what's in that :body ByteArrayInputStream ? there might a useful error description in there...

jjttjj17:10:38

Ah!

"{\"message\":\"User-Agent header is required.\"}"
that explains it. Thanks for the help!

euccastro21:10:49

yes, clj-http and other libraries that try and imitate that do supply a "User-Agent" on their own. bit me when porting code from that to Aleph