VirtualBox

Ignore:
Timestamp:
Sep 6, 2018 4:14:13 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/time: Extended RTTimeToRfc2822 with a flag for specifying RFC-7231 behaviour. Added simple testcase for it. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBaseOci.cpp

    r74122 r74125  
    6060    RTTIME     Now;
    6161    char       szDate[RTTIME_RTC2822_LEN];
    62     ssize_t cch = RTTimeToRfc2822(RTTimeExplode(&Now, RTTimeNow(&NowSpec)), szDate, sizeof(szDate));
     62    ssize_t cch = RTTimeToRfc2822(RTTimeExplode(&Now, RTTimeNow(&NowSpec)), szDate, sizeof(szDate), RTTIME_RFC2822_F_GMT);
    6363    AssertRCReturn((int)cch, (int)cch);
    64 
    65     /*
    66      * RFC2822 (RFC5322) marks "GMT" as obsolete,
    67      * but RFC7231 explicitly specifies in the grammar:
    68      *
    69      *   GMT = %x47.4D.54 ; "GMT", case-sensitive
    70      */
    71     if (   cch >= 5
    72         && (szDate[cch-5] == '-' || szDate[cch-5] == '+')
    73         && strcmp(&szDate[cch-5+1], "0000") == 0)
    74     {
    75         szDate[cch-5+0] = 'G';
    76         szDate[cch-5+1] = 'M';
    77         szDate[cch-5+2] = 'T';
    78         szDate[cch-5+3] = '\0';
    79         cch -= 2;
    80     }
    8164
    8265    return RTHttpAddHeader(hHttp, "x-date", szDate, cch, RTHTTPADDHDR_F_BACK);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette