I read the documentation about the upgrade to update calls for http_request and http_request_update.
I had a few try with a sample repo, a canister on mainnet (https://okoji-rqaaa-aaaap-qasma-cai.raw.ic0.app/) and I do indeed notice that I have to set upgrade = true in the http_request response if I want to provide update calls and therefore support the service worker. Otherwise it throws an error Body does not pass verification.
However now, I am confuse about how to NOT set upgrade = true, i.e. set update = false, for the raw domain?
How can I detect that the request is made for the raw domain and therefore the update call can be spared!?!?
(pseudo code)
public shared query func http_request(request : HttpRequest) : async HttpResponse {
{
upgrade = ?true; // <----- here how to set false or true?!?!
body = Blob.toArray(Text.encodeUtf8("Yolo"));
headers;
status_code = 200;
streaming_strategy = null;
};
};
public shared func http_request_update(request : HttpRequest) : async HttpResponse {
{
upgrade = ?false; // <----- here always false or null right?
body = Blob.toArray(Text.encodeUtf8("Yolo"));
headers;
status_code = 200;
streaming_strategy = null;
};
};
Note: in this feature I want the canister to provide the same content, an index.html file, over .raw.ic0.app and .ic0.app. Itās a ācustom asset canisterā.
Yes it does but then Iām confuse why the service worker fails
If I donāt implement the upgrade = true and the method http_request_update then when I access the non raw domain canister-id.ic0.app the service worker fails with following error
The reason is that the service worker expects a certification header to be set by the canister using certified variables when you do http_request (query call). An update call on the other hand goes through consensus and is certified by default.