jussi-kalliokoski / gulp-awspublish-router

A router for defining file-specific rules with gulp-awspublish

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow setting custom headers

Jos512 opened this issue · comments

I'd like to use gulp-awspublish-router to set custom headers based on file patterns. For instance, the Link header allows for server push when using HTTP/2 (source and more info).

For custom headers like that one, the problem is two fold:

  • It seems there isn't a way to access the path of the file currently processed. We need that to create headers like
Link: </images/drucken.jpg>; rel=preload; as=image
  • It seems some filtering happens; setting Content-Type headers work, but a Link header fails. For instance:
"^.+\\.(?:js|css)": {
    cacheTime: 691200,      // 8 days
    gzip: true,
    headers:
    {
        "Link": "Test"
    }
}

Generates:

UnexpectedParameter: Unexpected key 'Link' found in params
    at ParamValidator.fail (I:\node_modules\aws-sdk\lib\param_validator.js:50:37)
    at ParamValidator.validateStructure (I:\node_modules\aws-sdk\lib\param_validator.js:77:14)
    at ParamValidator.validateMember (I:\node_modules\aws-sdk\lib\param_validator.js:88:21)
    at ParamValidator.validate (I:\node_modules\aws-sdk\lib\param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (I:\node_modules\aws-sdk\lib\event_listeners.js:108:42)
    at Request.callListeners (I:\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
    at callNextListener (I:\node_modules\aws-sdk\lib\sequential_executor.js:95:12)
    at I:\node_modules\aws-sdk\lib\event_listeners.js:74:9
    at finish (I:\node_modules\aws-sdk\lib\config.js:308:7)
    at I:\node_modules\aws-sdk\lib\config.js:324:9

(Creating a Content-Type: Test header works fine, on the other hand.)