Skip to content

HttpClient.cpp#setCookie() #7076

Closed
@fvaryu

Description

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

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

Metadata

Assignees

Labels

Type

No type

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions