我试图找出一个项目的可行性,我希望能够在每个请求上运行一个脚本(最好通过MIMEtypes进行过滤),并运行一个脚本来设置响应头。
基本上我想要的文本/ HTML和应用程序/ JSON文件的HTTP头由系统生成的任意数据(实际头添加将是GIT分支和提交哈希信息)。
这是为本地和分期的networking服务器,所以性能影响不是高度关注。
我已经用bash脚本调查了mod_ext_filter,并且我可以成功地将string注入到输出中,但是我无法访问标题(我假设它们已经被发送了?)
还有其他的select,我可以调查?
我到目前为止的尝试(在虚拟主机中):
ExtFilterDefine githeaders mode=output \ cmd="/bin/bash /path/to/script/git_headers.sh" preservescontentlength <Location /> SetOutputFilter githeaders </Location>
基本的bash脚本testing回声
#!/bin/bash echo "hello" cat
上面的工作正常,向响应中注入hello,但我不能解决如何更改标题。 任何帮助/build议表示赞赏。
我所看到的例子通常使用mod_headers插入,删除或replace标题,如下面的手册中的示例。
# mod_ext_filter directive to define the external filter ExtFilterDefine gzip mode=output cmd=/bin/gzip <Location /gzipped> # core directive to cause the gzip filter to be # run on output SetOutputFilter gzip # mod_header directive to add # "Content-Encoding: gzip" header field Header set Content-Encoding gzip </Location>
我只能假设使用常规的API并通过在C中编写filter,您可以获得更多的访问权限,并且可以修改标题。