chucker icon indicating copy to clipboard operation
chucker copied to clipboard

charset=UTF-8 is not showing

Open ilizma opened this issue 4 years ago • 3 comments

:writing_hand: Describe the bug

On the REQUEST tab, charset=UTF-8 is not showing on the header zone

:bomb: Steps to reproduce

  1. Make an API call with okHttp that adds the header charset=UTF-8 automatically
  2. go to Chucker and click the tab REQUEST
  3. See the header zone
  4. charset=UTF-8 is not showing

:wrench: Expected behavior

charset=UTF-8 is showing on the header zone

ilizma avatar Apr 25 '20 17:04 ilizma

Thanks for reporting @ilizma I was able to reproduce locally. We actually just show the headers that OkHTTP passes us. Specifically we should append the Request content-type to the View in the Request tab.

Here a screenshot from Charles for the /post request:

Screenshot 2020-04-28 at 00 31 33

cortinico avatar Apr 27 '20 22:04 cortinico

The problem is that these headers are added as a part of OkHttp after application interceptors and before network interceptors do their work. The only thing that Chucker could do here if used as an application interceptor is to not process the request that is in the chain but rather one that is being returned by the interceptor.

Basically it would have to do something like this.

override fun intercept(chain: Chain): Response {
  // Some code…

  try {
    val response = chain.proceed(chain.request())
    val responseForRequest = response.networkResponse() ?: response
    val requestToProcess = response.request()
    // Process the request
  } catch (e: IOException) {
    // Do whatever
  }

  // Some code…
}

But I don't think it is a good feature. Now, in case of an application interceptor, it mixes an application response with a network request. So it should always process a network response instead of an application response for the consistency. But at this point Chucker loses the flexibility of being used as an application interceptor. Another drawback is that requests are processed later or might not be processed at all in case of response failures.

I believe it should be up to the consumer. If they are interested in network traffic then use Chucker as a network interceptor.

MiSikora avatar Apr 30 '20 21:04 MiSikora

I believe it should be up to the consumer. If they are interested in network traffic then use Chucker as a network interceptor.

Agree on this point. I would avoid to do extra processing for exposing headers that are added by the library.

My suggestion was more related to:

Specifically we should append the Request content-type to the View in the Request tab.

We actually store the request content-type in the DB but we never show it to the user.

cortinico avatar May 11 '20 16:05 cortinico

Is this still up for grabs? Do we want to display the content-type in the Overview tab or the Request tab?

ArjanSM avatar Dec 13 '22 00:12 ArjanSM

Is this still up for grabs? Do we want to display the content-type in the Overview tab or the Request tab?

Yup this is up for grab 👍

cortinico avatar Dec 13 '22 14:12 cortinico

I don't think there is anything to grab. We already discussed in issues like https://github.com/ChuckerTeam/chucker/issues/474 that Content-type appears or not depending in type of interceptor that user adds.

vbuberen avatar Dec 13 '22 22:12 vbuberen

I don't think there is anything to grab. We already discussed in issues like #474 that Content-type appears or not depending in type of interceptor that user adds.

Yup I misread my actual 2 year old response 🤦 We store content-type in the DB but it's pointless to manipulate the visualized header, and is up to the user to decide which interceptor to use. I'm closing as there are no actionables

cortinico avatar Dec 13 '22 23:12 cortinico