github remix-run/remix @remix-run/headers@0.19.0
@remix-run/headers v0.19.0

latest releases: remix@3.0.0-alpha.0, @remix-run/static-middleware@0.4.1, @remix-run/file-storage@0.13.1...
10 hours ago

Minor Changes

  • BREAKING CHANGE: Removed Headers/SuperHeaders class and default export. Use the native Headers class with the static from() method on each header class instead.

    New individual header .from() methods:

    • Accept.from()
    • AcceptEncoding.from()
    • AcceptLanguage.from()
    • CacheControl.from()
    • ContentDisposition.from()
    • ContentRange.from()
    • ContentType.from()
    • Cookie.from()
    • IfMatch.from()
    • IfNoneMatch.from()
    • IfRange.from()
    • Range.from()
    • SetCookie.from()
    • Vary.from()

    New raw header utilities added:

    • parse()
    • stringify()

    Migration example:

    // Before:
    import SuperHeaders from '@remix-run/headers'
    let headers = new SuperHeaders(request.headers)
    let mediaType = headers.contentType.mediaType
    
    // After:
    import { ContentType } from '@remix-run/headers'
    let contentType = ContentType.from(request.headers.get('content-type'))
    let mediaType = contentType.mediaType

    If you were using the Headers constructor to parse raw HTTP header strings, use parse() instead:

    // Before:
    import SuperHeaders from '@remix-run/headers'
    let headers = new SuperHeaders('Content-Type: text/html\r\nCache-Control: no-cache')
    
    // After:
    import { parse } from '@remix-run/headers'
    let headers = parse('Content-Type: text/html\r\nCache-Control: no-cache')

    If you were using headers.toString() to convert headers to raw format, use stringify() instead:

    // Before:
    import SuperHeaders from '@remix-run/headers'
    let headers = new SuperHeaders()
    headers.set('Content-Type', 'text/html')
    let rawHeaders = headers.toString()
    
    // After:
    import { stringify } from '@remix-run/headers'
    let headers = new Headers()
    headers.set('Content-Type', 'text/html')
    let rawHeaders = stringify(headers)

Don't miss a new remix release

NewReleases is sending notifications on new releases.