On Thu, Nov 21, 2013 at 8:31 PM, James Peach <[email protected]> wrote:
> On Nov 21, 2013, at 8:23 PM, Mark Moseley <[email protected]> wrote: > > > I've been perusing the code but not finding anything. Was hoping someone > could give me a pointer where in the code I could add headers that ATS > sends back with 304 Responses, if that's even possible. I want to add some > custom headers (cf. apache httpd, in modules/http/http_filters.c line 1281). > > > > Or even better yet, a configuration option that I haven't stumbled > across yet :) > > You can do this using the header_rewrite plugins, see the example here < > https://github.com/apache/trafficserver/tree/master/plugins/header_rewrite/Examples>. > The documentation for this is *ahem* sparse, but if you poke zwoop on IRC > he will help you out ... I was a bit vague (I shouldn't write emails after a long day). I should've included some details like: ATS 4.1.1 and that I'm trying to get ATS to add headers to its own 304 responses. Giving headers_rewrite a try. cond %{SEND_RESPONSE_HDR_HOOK} add-header X-ATS-1 %{HEADER:X-From-Apache} cond %{SEND_RESPONSE_HDR_HOOK} add-header X-ATS-2 Hi To test this, I created a dummy header called X-From-Apache that's getting added via .htaccess. For a "Pragma: no-cache" request, ATS is indeed copying it over into X-ATS-1, along with just setting X-ATS-2. So far so good. > GET /test.html HTTP/1.1 > User-Agent: curl/7.30.0 > Accept: */* > Pragma: no-cache > Host: example.com > < HTTP/1.1 200 OK < Date: Fri, 22 Nov 2013 18:42:13 GMT < Content-Type: text/html < Content-Length: 2 < Connection: keep-alive < Server: Apache/2 < X-From-Apache: Hi from apache < Last-Modified: Fri, 22 Nov 2013 18:41:52 GMT < ETag: "2-4ebc85e219631" < Accept-Ranges: bytes < Cache-Control: max-age=3600 < Expires: Fri, 22 Nov 2013 19:42:13 GMT < Vary: Accept-Encoding < Age: 0 < X-ATS-1: Hi from apache < X-ATS-2: Hi For the conditional request though, ATS added that one explicit header but didn't copy over X-From-Apache: > GET /test.html HTTP/1.1 > User-Agent: curl/7.30.0 > Accept: */* > If-Modified-Since: Fri, 22 Nov 2013 18:41:52 GMT > Host: example.com > < HTTP/1.1 304 Not Modified < Date: Fri, 22 Nov 2013 18:42:36 GMT < Connection: keep-alive < Etag: "2-4ebc85e219631" < Expires: Fri, 22 Nov 2013 19:42:13 GMT < Cache-Control: max-age=3600 < Vary: Accept-Encoding < X-ATS-2: Hi If I send a non-conditional request (but without the Pragma: no-cache like in the first example), I get X-ATS-1 like in the Pragma: no-cache example. So 200 responses, whether cached or not cached, are getting the header copied over by headers_rewrite, just not in 304's. Is the not copying headers for a 304 expected behavior or should I open a ticket about it?
