arduino-esp32 icon indicating copy to clipboard operation
arduino-esp32 copied to clipboard

HttpClient.cpp#setCookie()

Open fvaryu opened this issue 2 years ago • 2 comments

Board

ESP32Dev Kit

Device Description

DevKit

Hardware Configuration

none

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

macOS

Flash frequency

40Mhz

PSRAM enabled

no

Upload speed

115200

Description

HttpClient.cpp#setCookie()

void HTTPClient::setCookie(String date, String headerValue)
{
    if (!_cookieJar)
    {
        return;
    }
    #define HTTP_TIME_PATTERN "%a, %d %b %Y %H:%M:%S"

    Cookie cookie;
    String value;
    int pos1, pos2;

    headerValue.toLowerCase(); // ? why toLoerCase()
  // other code
}

Why turn the value into lowercase, if the server returns uppercase? i don't understand。thx

  CookieJar cookies;
  http.setCookieJar(&cookies);

The server returns a mixed case token, but I get lowercase by CookieJar

Sketch

void HTTPClient::setCookie(String date, String headerValue)
{
    if (!_cookieJar)
    {
        return;
    }
    #define HTTP_TIME_PATTERN "%a, %d %b %Y %H:%M:%S"

    Cookie cookie;
    String value;
    int pos1, pos2;

   headerValue.toLowerCase();

    struct tm tm;
    strptime(date.c_str(), HTTP_TIME_PATTERN, &tm);
    cookie.date = mktime(&tm);
}

Debug Message

None

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.

fvaryu avatar Aug 02 '22 07:08 fvaryu

Hummm..... that seems a bug. Cookies are case sensitive. Thanks @fvaryu for pointing that out.

SuGlider avatar Aug 02 '22 18:08 SuGlider

@fvaryu - If possible, please test the PR #7112 and let me know if it fixes the issue. Thanks.

SuGlider avatar Aug 10 '22 20:08 SuGlider