Getting 403 forbidden error in Get request using http4s

273 Views Asked by At

I am doing a short assignment in http4s and I am getting 403 error from a long time which is difficult to debug. My code is:

object Assignment extends App {
  implicit val cs: ContextShift[IO] = IO.contextShift(global)
  implicit val timer: Timer[IO] = IO.timer(global)
  val blockingPool = Executors.newFixedThreadPool(5)
  val blocker = Blocker.liftExecutorService(blockingPool)
  val httpClient: Client[IO] = JavaNetClientBuilder[IO](blocker).create
  //val httpize = Uri.uri("http://httpize.herokuapp.com")

  def get() = {
    /*val target = uri("http://www.randomtext.me/download/txt/lorem/p-1/10-35/")
    val req = Request(method = Method.GET, uri = target)*/
    val ioString = httpClient.expect[String]("http://www.randomtext.me/download/txt/lorem/p-1/10-35/")
    val futu = ioString.map(x => x)
    futu.map(_.mkString).unsafeRunSync()





  }
  /*def post() = {
    val req = Request(method = Method.POST, uri = httpize / "post").withBody("hello")
    val task = httpClient.
    val x = task.unsafePerformSync
    println(x)
  }*/
  get()

  // post()

}
0

There are 0 best solutions below