This repository has been archived by the owner. It is now read-only.
Kotlin HTTP requests library. Similar to Python requests.
Kotlin
Switch branches/tags
Nothing to show
Clone or download
Latest commit 94ddc37 Sep 8, 2017
mb-vsn authored and jkcclemens committed Sep 8, 2017 Support HTTP 307 and HTTP 308 redirects
This commit provides support for following HTTP 307 and HTTP 308
redirects. Specifically, the `URL.openRedirectingConnection` function
(located in `GenericResponse.kt`) was updated to check for the HTTP
response code's presence in an array of redirect response codes
(301, 302, 303, 307, and 308). Previously, the function was only
checking for response codes in the range 301..303.

For information regarding these additional HTTP status codes, see:
  - [307 Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7)
  - [308 Permanent Redirect](https://tools.ietf.org/html/rfc7538#section-3)

README.md

khttp

Travis CI Codecov VersionEye License Gratipay Documentation status

khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module.

import khttp.get

fun main(args: Array<out String>) {
    // Get our IP
    println(get("http://httpbin.org/ip").jsonObject.getString("origin"))
    // Get our IP in a simpler way
    println(get("http://icanhazip.com").text)
}

Dependency

Stable

Stable releases are hosted on JCenter.

<repository>
  <id>jcenter</id>
  <url>http://jcenter.bintray.com/</url>
</repository>
<!-- ... -->
<dependency>
  <groupId>khttp</groupId>
  <artifactId>khttp</artifactId>
  <version>0.1.0</version>
</dependency>

Development

Development builds are currently available through JitPack. Snapshot builds may eventually be hosted on OJO, but are not currently available there.