question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot access request header fields after connection is set

See original GitHub issue

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"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
molchanovivcommented, Dec 4, 2017

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

0reactions
kittinunfcommented, Aug 1, 2018

Let’s close this as it looks quite stale to me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found