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

sttp.client4.PartialRequestExtensions.scala Maven / Gradle / Ivy

The newest version!
package sttp.client4

import sttp.client4.internal.SttpFile
import org.scalajs.dom.File

trait PartialRequestExtensions[+R <: PartialRequestBuilder[R, _]] { self: R =>

  /** If content type is not yet specified, will be set to `application/octet-stream`.
    *
    * If content length is not yet specified, will be set to the length of the given file.
    */
  def body(file: File): R = body(SttpFile.fromDomFile(file))

  // this method needs to be in the extensions, so that it has lowest priority when considering overloading options
  /** If content type is not yet specified, will be set to `application/octet-stream`.
    */
  def body[B: BodySerializer](b: B): R =
    withBody(implicitly[BodySerializer[B]].apply(b))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy