Skip to content

How to use void handleHandshake(AwsHandshakeHandler handler) for cookie handling? #13

@DaeMonSxy

Description

@DaeMonSxy

How to use properly the cookie auth instead of request->authenticate ?
Do we need to use it for webpages and ws also, or only in server.on- (headers request) enough?

WServer.on("/syst", HTTP_GET, [](AsyncWebServerRequest *request) {
        sendHTMLResponse(request, system_html, sizeof(system_html), (TEXT_HTML), P_SYSTEM);
    });


void sendHTMLResponse(AsyncWebServerRequest *request, const uint8_t *htmlContent, size_t htmlSize, const char *contentType, html_pages_t setpage)
{
   
  if (dev_auth && !request->authenticate(dev_user, dev_pass))
        return request->requestAuthentication();
 

#if defined(ESP32)
    AsyncWebServerResponse *response = request->beginResponse(200, contentType, htmlContent, htmlSize);
#elif defined(ESP8266)
    AsyncWebServerResponse *response = request->beginResponse_P(200, contentType, htmlContent, htmlSize);
#endif

    response->addHeader((CONTENT_ENCODING), (GZIP));
    request->send(response);

    current_html_page = setpage;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions