Skip to content

Commit

Permalink
πŸš‘ check for empty time / set unparsable time to blank
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzyStatic committed Mar 28, 2021
1 parent daa01ec commit 1204ff3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions v2/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ func getHeader(httpHeader http.Header) (*Header, error) {
XTraceParentSpanID: httpHeader.Get(HeaderKeyXTraceSpanID),
XTraceTraceID: httpHeader.Get(HeaderKeyXTraceTraceID),
}
header.Date, err = time.Parse(time.RFC1123, httpHeader.Get(HeaderKeyDate))
if err != nil {
return &header, err
if httpHeader.Get(HeaderKeyDate) != "" {
header.Date, err = time.Parse(time.RFC1123, httpHeader.Get(HeaderKeyDate))
if err != nil {
header.Date = time.Time{}
}
}
header.LastModified, err = time.Parse(time.RFC1123, httpHeader.Get(HeaderKeyLastModified))
if err != nil {
return &header, err
if httpHeader.Get(HeaderKeyLastModified) != "" {
header.LastModified, err = time.Parse(time.RFC1123, httpHeader.Get(HeaderKeyLastModified))
if err != nil {
header.LastModified = time.Time{}
}
}
return &header, nil
}

0 comments on commit 1204ff3

Please sign in to comment.