Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    import $ivy.`com.lihaoyi::requests:0.1.5`
    val r = requests.post("http://httpbin.org/post", data = Map("key" -> "value"))
    Do you know what's misssing ?
    $ ./HttpClient-requests.scala
    Exception in thread "main" java.lang.ClassNotFoundException: $file.`HttpClient-requests`$$routes$
            at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
            at ammonite.interp.SpecialClassLoader.findClass(ClassLoaders.scala:113)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    I updated from ammonite 0.7 to ammonite 1.2, it solved the problem
    Faiaz Sanaulla
    Hello, @lihaoyi thank you for a great project.
    Can you tell me why response headers lowercased by default?
    Why not leave it as it is?
    Nick Childers
    Does requests-scala support downloading chunked gzip files?
    Romain DEP.
    hi there, thumbs up for the great lib.
    Are there any plans to support other kind of proxys? Seems like socks5 isn't supported currently
    Jamal CHAQOURI

    Hi, I think it's not directly related to requests-scala, i did find a simple to do it, let met explain :

    • I create a session for qualifEnv (let us say baseUrl: https://qualif.gatway): `val qualifEnv = requests.Session(some specific config for qualif)
    • Now i do a call: qualifEnvSession.get(s"$baseUrl/resource", ...)

    It could be cool to have a scoped requests instance allowing: qualifEnvSession.get("resource", ...), which takes care about addding the baseUrl.

    I did not find a simple way to do that, if have you ideas, thank you

    with geny.Readable and geny.Writable, and a scoped by env requests instance, we could have a less error prone and smooth tool for data migration between envs
    Nicolas A Perez
    do we have support for proxies on this library?
    @lihaoyi I have been using the lib for a while now, but i need to go through a proxy. Does the library support proxy as the python one?
    Andreas Joseph Krogh

    I'm feeling that the way this library is going forces me to use var more than it should.
    If reading a stream from GET I have to use a var to store the StreamHeaders value and then only read from the stream if response is SC_OK, like this:

    var responseHeaders: Option[StreamHeaders] = None
    requests.get.stream("https://some.url", check = false
        , onHeadersReceived = streamHeaders => {
            responseHeaders = Some(streamHeaders)
            if (streamHeaders.statusCode == HttpServletResponse.SC_OK) {
                // stuff
            } else {
                // other stuff
        }).readBytesThrough{ inputStream =>
        if (responseHeaders.exists(_.statusCode == HttpServletResponse.SC_OK)) {
            // read stream
        } else {
            // don't

    It would be great if one could do this (access streamHeaders in the Readable:

    val readable = requests.get.stream("https://some.url", check = false
        , onHeadersReceived = streamHeaders => {
            if (streamHeaders.statusCode == HttpServletResponse.SC_OK) {
                // stuff
            } else {
                // other stuff
    if (readable.streamHeaders.statusCode == HttpServletResponse.SC_OK) {
        readable.readBytesThrough{ inputStream =>
            // read stream

    i've been working with requests-scala in an (sbt 1.3.7/scala 2.13.1) app with utests without any problems, as per:

    "com.lihaoyi" %% "requests" % "0.5.0",

    however, when i run an ammonite script mimicking the successful utest with ammonite 1.6.3 (scala 2.12.8 on macOS 10.15.3):

    import $ivy.`com.lihaoyi::requests:0.5.0`
    import $ivy.`com.lihaoyi::pprint:0.5.6`, pprint._
    // requires fsm-interface.FsmInterface to be up and running
    val host = "http://localhost:8080"
    val resp = requests.get(s"$host/echo")

    i get

    Compiling /Users/psc/Documents/Development/Scala/fsm/interface/src/main/sc/fsm-interface.sc
    fsm-interface.sc:6: Symbol 'type geny.ByteData' is missing from the classpath.
    This symbol is required by 'class requests.Response'.
    Make sure that type ByteData is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
    A full rebuild may help if 'Response.class' was compiled against an incompatible version of geny.
    val resp = requests.get(s"$host/echo")
    fsm-interface.sc:8: value text is not a member of requests.Response
    val res_5 = pprintln(resp.text())
    Compilation Failed

    (the pprint import works fine and can be used.)


    problem above goes away using latest ammonite installed via coursier / cs CLI.

    might be time to move in a coursier / mill direction and away from sbt...

    (altho sbt 1.3.x apparently uses coursier out of the box anyway…)