gulp-awspublish-router icon indicating copy to clipboard operation
gulp-awspublish-router copied to clipboard

Allow setting custom headers

Open Jos512 opened this issue 8 years ago • 0 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.)

Jos512 avatar Feb 23 '17 17:02 Jos512