The date/time format used in HTTP headers

前端 未结 4 1399
甜味超标
甜味超标 2021-02-02 05:58

Which RFC describes the format used for date/time in the modern time HTTP headers, like \"Last-Modified\" and \"If-Modified-Since\", and how to generate a date/time string in PH

4条回答
  •  臣服心动
    2021-02-02 06:20

    I'm pretty sure the (now) correct answer here is rfc7231 - section 7.1.1.1 It specifies Date/Time Formats and is where the HTTP-date semantics are defined.

    HTTP-date    = IMF-fixdate / obs-date
    

    Also we can see that

    When a sender generates a header field that contains one or more timestamps defined as HTTP-date, the sender MUST generate those timestamps in the IMF-fixdate format.

    So for a server sending a "modern time HTTP header"- where the value is a HTTP-date the format is equivalent to the IMF-fixdate format.

    So to answer the actual question.

    Which RFC describes the format used for date/time in the modern time HTTP headers

    You need to know the definition of IMF-fixdate - which is in rfc7231. It also give the definition of obs-date too i.e rfc850-date / asctime-date

         IMF-fixdate  = day-name "," SP date1 SP time-of-day SP GMT
         ; fixed length/zone/capitalization subset of the format
         ; see Section 3.3 of [RFC5322]
    
         day-name     = %x4D.6F.6E ; "Mon", case-sensitive
                      / %x54.75.65 ; "Tue", case-sensitive
                      / %x57.65.64 ; "Wed", case-sensitive
                      / %x54.68.75 ; "Thu", case-sensitive
                      / %x46.72.69 ; "Fri", case-sensitive
                      / %x53.61.74 ; "Sat", case-sensitive
                      / %x53.75.6E ; "Sun", case-sensitive
    
    
         date1        = day SP month SP year
                      ; e.g., 02 Jun 1982
    
         day          = 2DIGIT
         month        = %x4A.61.6E ; "Jan", case-sensitive
                      / %x46.65.62 ; "Feb", case-sensitive
                      / %x4D.61.72 ; "Mar", case-sensitive
                      / %x41.70.72 ; "Apr", case-sensitive
                      / %x4D.61.79 ; "May", case-sensitive
                      / %x4A.75.6E ; "Jun", case-sensitive
                      / %x4A.75.6C ; "Jul", case-sensitive
                      / %x41.75.67 ; "Aug", case-sensitive
                      / %x53.65.70 ; "Sep", case-sensitive
                      / %x4F.63.74 ; "Oct", case-sensitive
                      / %x4E.6F.76 ; "Nov", case-sensitive
                      / %x44.65.63 ; "Dec", case-sensitive
         year         = 4DIGIT
    
         GMT          = %x47.4D.54 ; "GMT", case-sensitive
    
         time-of-day  = hour ":" minute ":" second
                      ; 00:00:00 - 23:59:60 (leap second)
    
         hour         = 2DIGIT
         minute       = 2DIGIT
         second       = 2DIGIT
    
       Obsolete formats:
    
         obs-date     = rfc850-date / asctime-date
    
         rfc850-date  = day-name-l "," SP date2 SP time-of-day SP GMT
         date2        = day "-" month "-" 2DIGIT
                      ; e.g., 02-Jun-82
    
         day-name-l   = %x4D.6F.6E.64.61.79    ; "Monday", case-sensitive
                / %x54.75.65.73.64.61.79       ; "Tuesday", case-sensitive
                / %x57.65.64.6E.65.73.64.61.79 ; "Wednesday", case-sensitive
                / %x54.68.75.72.73.64.61.79    ; "Thursday", case-sensitive
                / %x46.72.69.64.61.79          ; "Friday", case-sensitive
                / %x53.61.74.75.72.64.61.79    ; "Saturday", case-sensitive
                / %x53.75.6E.64.61.79          ; "Sunday", case-sensitive
    
    
         asctime-date = day-name SP date3 SP time-of-day SP year
         date3        = month SP ( 2DIGIT / ( SP 1DIGIT ))
                      ; e.g., Jun  2
    

提交回复
热议问题