VirtualBox

Ignore:
Timestamp:
Sep 6, 2018 3:10:20 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rest: When we generate X-Date header we use RTTimeToRfc2822.
RFC2822 (RFC5322) marks "GMT" as obsolete, but RFC7231 explicitly
specifies literal "GMT" in the grammar (7.1.1.1), so replace final
"-0000" or "+0000" with "GMT" to make the server happy.

File:
1 edited

Legend:

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

    r74070 r74122  
    6262    ssize_t cch = RTTimeToRfc2822(RTTimeExplode(&Now, RTTimeNow(&NowSpec)), szDate, sizeof(szDate));
    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    }
    6481
    6582    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