weolar / miniblink49

a lighter, faster browser kernel of blink to integrate HTML UI in your app. 一个小巧、轻量的浏览器内核,用来取代wke和libcef
Apache License 2.0
7.15k stars 1.07k forks source link

How to use wkeNetSetHTTPHeaderField ? #595

Open lexesv opened 5 days ago

lexesv commented 5 days ago

Hello. Please help. No headers are added to the request.

bool LoadUrlBeginCallback(wkeWebView webView, void *param, const utf8 *url, wkeNetJob job) {
    wkeNetSetHTTPHeaderField(job, (const wchar_t *) "accept", (const wchar_t *) "application/json, text/javascript, */*; q=0.01", false);
    wkeNetSetHTTPHeaderField(job, (const wchar_t *) "x-requested-with", (const wchar_t *) "XMLHttpRequest", false);
    wkeNetHookRequest(job);
    return false;
}

wke version 1.02 blink build 98096 build time Sat Aug 5 14:09:29 2023

void initBlink() {

    char cCurrentPath[FILENAME_MAX];
    GetCurrentDir(cCurrentPath, sizeof(cCurrentPath));
    char dllpath[MAX_PATH];
    strcpy(dllpath, (const char *) cCurrentPath);
    strcat(dllpath, "\\node.dll");

    size_t cSize = strlen(dllpath) + 1;
    wchar_t *wdllpath = (wchar_t *) malloc(sizeof(wchar_t) * cSize);
    mbstowcs(wdllpath, dllpath, cSize);

    HMODULE hMod = LoadLibraryW(wdllpath);
    FN_wkeInitializeEx wkeInitializeExFunc = (FN_wkeInitializeEx) GetProcAddress(hMod, "wkeInitializeEx");
    wkeInitializeExFunc((wkeSettings *) 0);
    WKE_FOR_EACH_DEFINE_FUNCTION(WKE_GET_PTR_ITERATOR0, WKE_GET_PTR_ITERATOR1, WKE_GET_PTR_ITERATOR2,
                                 WKE_GET_PTR_ITERATOR3,
                                 WKE_GET_PTR_ITERATOR4, WKE_GET_PTR_ITERATOR5, WKE_GET_PTR_ITERATOR6,
                                 WKE_GET_PTR_ITERATOR11);

    free(wdllpath);
}

Maybe a newer version of node.dll is needed? If it is, can you share it?

weolar commented 5 days ago

wkeNetSetHTTPHeaderField(job, (const wchar_t ) L"accept", (const wchar_t ) L"application/json, text/javascript, /; q=0.01", false); wkeNetSetHTTPHeaderField(job, (const wchar_t ) L"x-requested-with", (const wchar_t ) L"XMLHttpRequest", false);

lexesv commented 5 days ago

wkeNetSetHTTPHeaderField(job, (const wchar_t ) L"accept", (const wchar_t ) L"application/json, text/javascript, /; q=0.01", false); wkeNetSetHTTPHeaderField(job, (const wchar_t ) L"x-requested-with", (const wchar_t ) L"XMLHttpRequest", false);

Thank you very very very much!