jorgenbuilder / ic-inspector

⭐⭐⭐⭐⭐ Chrome extension for decoding responses from the Internet Computer blockchain
https://chromewebstore.google.com/detail/ic-inspector/meaadkenfkhjakkkdapaallimhbdofck?hl=en&authuser=0
MIT License
52 stars 9 forks source link

When the requested content-type is text, but the returned type is cbor, it cannot be captured #34

Closed Ox-apex closed 1 year ago

Ox-apex commented 1 year ago

When the requested content-type is text, but the returned type is cbor, it cannot be captured. This is because only the parsing of requests and responses with cbor types is implemented in the code. Let's see how to support this. image

jorgenbuilder commented 1 year ago

In what cases would content-type be text?

Ox-apex commented 1 year ago

in "status" case request is text ,but the response is cbor

jorgenbuilder commented 1 year ago

Ah, I understand what you mean by this (finally 😆)

/**
 * Determines whether the request uses a cbor content type.
 */
export function isCBOR(event: chrome.devtools.network.Request): boolean {
    return event.request.headers.some(
        (h) => h.name === 'content-type' && h.value.includes('cbor'),
    );
}

The selection code above only works when the request uses cbor. I'll look into it.

jorgenbuilder commented 1 year ago

Latest version inspects response headers instead of request headers. Works well in my local testing so far, let's see how it does in production.