fuel: Cannot access request header fields after connection is set

Attempting to execute:

"http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en".httpGet().response { request, response, result -> 
     println(request)
     println(response)
}

produces:

java.lang.IllegalStateException: Cannot access request header fields after connection is set
     at com.github.kittinunf.fuel.toolbox.HttpClient.executeRequest(HttpClient.kt:69)
     at com.github.kittinunf.fuel.core.requests.TaskRequest.call(TaskRequest.kt:16)
     at com.github.kittinunf.fuel.core.requests.AsyncTaskRequest.call(AsyncTaskRequest.kt:13)
     at com.github.kittinunf.fuel.core.requests.AsyncTaskRequest.call(AsyncTaskRequest.kt:6)
     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
     at com.github.kittinunf.fuel.core.FuelManager$executor$2$1$1.run(FuelManager.kt:49)
     at java.lang.Thread.run(Thread.java:761)

Using the cUrlLoggingRequestInterceptor I got the following curl that when executed on a terminal it works:

curl -i -H "Accept-Encoding:compress;q=0.5, gzip;q=1.0" "http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en"

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I also faced this exception. But it happens only when i enable advanced profiling. With disabled profiler it works well.