Cannot access request header fields after connection is set
See original GitHub issueAttempting 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"
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Cannot access request header fields after connection is set ...
Just put the method getInputStream() before the method getContentLength() : inputStream = connection.getInputStream(); int fileSize ...
Read more >Cannot access request header fields after connection is set
No idea how to reproduce, it was thrown at app launch. Actual Behavior Crashed the app 02-08 13:17:11.645 11370-12377/com.mytest.app.android ...
Read more >HttpURLConnectionImpl.java - Android Code Search
Calling disconnect() before a connection exists should have no effect. ... "Cannot access request header fields after connection is set");.
Read more >Cannot access request header fields after connection is ... - 简书
IllegalStateException: Cannot access request header fields after connection is set at com.android.okhttp.internal.huc.HttpURLConnectionImpl.
Read more >HTTP Error 431: 3 Ways to Fix Request Header Fields Too ...
If none of these methods work, look at your code. A lot of requests in the code cause this issue. In addition, some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also faced this exception. But it happens only when i enable advanced profiling. With disabled profiler it works well.
Let’s close this as it looks quite stale to me.