lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #10148] HTTPD add cookie support


From: Adam Baron
Subject: [lwip-devel] [patch #10148] HTTPD add cookie support
Date: Sun, 28 Nov 2021 14:29:47 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

URL:
  <https://savannah.nongnu.org/patch/?10148>

                 Summary: HTTPD add cookie support
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: vysocan
            Submitted on: Sun 28 Nov 2021 07:29:45 PM UTC
                Category: Contrib
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

Hello,

here is proposal to add cookie handling to HTTPD. It is quite simple and
require LWIP_HTTPD_DYNAMIC_HEADERS to send the cookies. Also leaving all
processing up to user application. Application then needs to provide following
example functions.

#define SET_COOKIE_SIZE 48
char setCookie[SET_COOKIE_SIZE];

char *httpd_set_cookies(const void *connection, const char *uri) {
  LWIP_UNUSED_ARG(uri);

  if (connection == verifiedConn) {
    verifiedConn = NULL; // Clear verified connection
    snprintf(setCookie, SET_COOKIE_SIZE, HDR_HTTP_RES_SET_COOKIE
"id=%08X\r\n", authorizedConn.id);
    return setCookie;
  }
  return NULL;
}

void httpd_received_cookies(const void *connection, const char *cookies) {
  const char *sessionId = strstr(cookies, "id=");
  if (sessionId != NULL) {
     uint32_t value = strtol(sessionId+3, NULL, 16);
     if (value == authorizedConn.id) {
       authorizedConn.conn = (uint32_t *)connection;
     }
  }
}



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 28 Nov 2021 07:29:45 PM UTC  Name: patch.diff  Size: 6KiB   By:
vysocan

<http://savannah.nongnu.org/patch/download.php?file_id=52365>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?10148>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]