All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mle.android.http.BasicHttpClient.scala Maven / Gradle / Ivy

The newest version!
package com.mle.android.http

import concurrent.duration._

/**
 * HTTP client that assumes the same endpoint is used for all requests.
 *
 * Therefore modifies the methods so that only the resource, not the
 * absolute URI, must be passed in when making requests.
 *
 * @author mle
 */
class BasicHttpClient(endpoint: IEndpoint)
  extends AuthHttpClient(endpoint.username, endpoint.password) {
  httpClient setTimeout (5 seconds).toMillis.toInt

  private def scheme = if (endpoint.protocol == Protocols.Https) "https" else "http"

  val baseUrl = s"$scheme://${endpoint.host}:${endpoint.port}"

  override def transformUri(uri: String): String = baseUrl + uri
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy