Skip to content

HttpClient.cpp#setCookie() #7076

Closed
@fvaryu

Description

@fvaryu

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.

Activity

self-assigned this
on Aug 2, 2022
SuGlider

SuGlider commented on Aug 2, 2022

@SuGlider
Collaborator

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

added this to the 2.0.5 milestone on Aug 3, 2022
SuGlider

SuGlider commented on Aug 10, 2022

@SuGlider
Collaborator

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

1 remaining item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions

    HttpClient.cpp#setCookie() · Issue #7076 · espressif/arduino-esp32