Etag instead of ETag

2,153 views
Skip to first unread message

mschlimp

unread,
Jul 24, 2012, 4:20:10 PM7/24/12
to golan...@googlegroups.com
Hi,

I set for my response Header a Etag for a resource by using this code:

writer.Header().Set("ETag",etag)

In the answer of the browser the ETag Header Attribute is written as Etag istead ETag and ignored by the Chrome or Safari Browser.

Is there a other way to set this ETag Header Attribute?

thx.
Marcel

 

Brad Fitzpatrick

unread,
Jul 24, 2012, 4:24:52 PM7/24/12
to mschlimp, golan...@googlegroups.com
Are you sure Chrome and Safari are ignoring it?  HTTP header names are case-insensitive.

André Moraes

unread,
Jul 24, 2012, 4:47:45 PM7/24/12
to mschlimp, golan...@googlegroups.com
> I set for my response Header a Etag for a resource by using this code:
>
> writer.Header().Set("ETag",etag)

You are calling this method before writing to the body, right?

--
André Moraes
http://amoraes.info

Marcel Schlimper

unread,
Jul 24, 2012, 5:05:54 PM7/24/12
to André Moraes, golan...@googlegroups.com
yes thats the whole function.

func Tracking_etag(c *goweb.Context) {
etag := c.Request.Header.Get("If-None-Match")
etag = etag + "1"
writer := c.ResponseWriter
writer.Header().Set("ETag",etag)
writer.Header().Set("If-None-Match",etag)
var templ = template.Must(template.New("qr").Parse(etag))
templ.Execute(writer,nil)
}

I deployed it to the google app engine. There it works for firefox and
chrome but not for safari....

Marcel Schlimper

unread,
Jul 24, 2012, 5:13:15 PM7/24/12
to André Moraes, golan...@googlegroups.com
you can try it here:

http://rtbstage.appspot.com/

tomwilde

unread,
Jul 24, 2012, 5:17:59 PM7/24/12
to golan...@googlegroups.com
As a side note, be careful about using E-Tags for tracking:


You could get sued.


Am Dienstag, 24. Juli 2012 23:05:54 UTC+2 schrieb mschlimp:
yes thats the whole function.

func Tracking_etag(c *goweb.Context) {
  etag := c.Request.Header.Get("If-None-Match")
  etag = etag + "1"
  writer := c.ResponseWriter
  writer.Header().Set("ETag",etag)
  writer.Header().Set("If-None-Match",etag)
  var templ = template.Must(template.New("qr").Parse(etag))
  templ.Execute(writer,nil)
}

I deployed it to the google app engine. There it works for firefox and
chrome but not for safari....

Marcel Schlimper

unread,
Jul 24, 2012, 5:37:40 PM7/24/12
to tomwilde, golan...@googlegroups.com

Dont worry. Its a playground not a real business case

Message has been deleted

elij

unread,
Jul 25, 2012, 12:54:01 AM7/25/12
to mschlimp, golan...@googlegroups.com
Header is just a map[string][]string under the hood. Have you tried something like...

// get header map
h := writer.Header()
// add etag to it with desired format
x["ETag"] = []string{"test"}



It does seem odd that formatting matters though.

elij

unread,
Jul 25, 2012, 12:56:52 AM7/25/12
to mschlimp, golan...@googlegroups.com
Of course without the typo on the last line *sigh*.
Should have read: h["ETag"] = []string{"test"}

Message has been deleted

Marcel Schlimper

unread,
Jul 25, 2012, 10:35:45 AM7/25/12
to Peter Russell, golan...@googlegroups.com
On Wed, Jul 25, 2012 at 7:11 AM, Peter Russell <retep....@ymail.com> wrote:
>> Of course without the typo on the last line *sigh*.
>> Should have read: h["ETag"] = []string{"test"}
>
>
> If that does not work, then try adding quotes to make it a valid entity tag:
> h["ETag"] = []string{"\"test\""}

it looks like sfari does not support / work with ETag

elij

unread,
Jul 25, 2012, 10:12:57 PM7/25/12
to Marcel Schlimper, Peter Russell, golan...@googlegroups.com


On Wednesday, July 25, 2012 at 7:35 AM, Marcel Schlimper wrote:

> On Wed, Jul 25, 2012 at 7:11 AM, Peter Russell <retep....@ymail.com (mailto:retep....@ymail.com)> wrote:
> > > Of course without the typo on the last line *sigh*.
> > > Should have read: h["ETag"] = []string{"test"}
> >
> >
> >
> >
> > If that does not work, then try adding quotes to make it a valid entity tag:
> > h["ETag"] = []string{"\"test\""}
>
>
>
> it looks like sfari does not support / work with ETag
I find that very surprising (especially since if I run ngrep locally with safari-6.0 traffic I can indeed see if-none-match headers in the request).

Are you setting any other headers that might be taking precedence (Vary, Cache-Control. etc)?

Marcel Schlimper

unread,
Jul 26, 2012, 2:56:54 AM7/26/12
to elij, Peter Russell, golan...@googlegroups.com
Hi,

is is the request from safari Version 5.1.7 (7534.57.2) without setting the ETag



GET / HTTP/1.1..Host: rtbstage.appspot.com..User-Agent: Mozilla/5.0
(Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (
KHTML, like Gecko) Version/5.1.7 Safari/534.57.2..Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8..Ca
che-Control: max-age=0..Accept-Language: de-de..Accept-Encoding:
gzip, deflate..Cookie: a=cookie:737060cd8c284d8af7ad3082f209
582d..Connection: keep-alive....

The same request with firefox:

GET / HTTP/1.1..Host: rtbstage.appspot.com..User-Agent: Mozilla/5.0
(Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101
Firefox/13.0.1..Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8..Accept-Language:
de-de,de;q=0.8,en-u
s;q=0.5,en;q=0.3..Accept-Encoding: gzip, deflate..Connection:
keep-alive..Cookie: a=cookie:737060cd8c284d8af7ad3082f209582d..
If-None-Match: "737060cd8c284d8af7ad3082f209582d"..Cache-Control:
max-age=0....


I think its not a problem of the/my go implementation.

elij

unread,
Jul 26, 2012, 1:29:52 PM7/26/12
to Marcel Schlimper, Peter Russell, golan...@googlegroups.com
On Wednesday, July 25, 2012 at 11:56 PM, Marcel Schlimper wrote:
> On Thu, Jul 26, 2012 at 4:12 AM, elij <eli...@gmail.com (mailto:eli...@gmail.com)> wrote:
> >
> >
> > On Wednesday, July 25, 2012 at 7:35 AM, Marcel Schlimper wrote:
> >
> > > On Wed, Jul 25, 2012 at 7:11 AM, Peter Russell <retep....@ymail.com (mailto:retep....@ymail.com)> wrote:
> > > > > Of course without the typo on the last line *sigh*.
> > > > > Should have read: h["ETag"] = []string{"test"}
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > If that does not work, then try adding quotes to make it a valid entity tag:
> > > > h["ETag"] = []string{"\"test\""}
> > >
> > >
> > >
> > >
> > >
> > > it looks like sfari does not support / work with ETag
> > I find that very surprising (especially since if I run ngrep locally with safari-6.0 traffic I can indeed see if-none-match headers in the request).
> >
> > Are you setting any other headers that might be taking precedence (Vary, Cache-Control. etc)?
>
>
> Hi,
>
> is is the request from safari Version 5.1.7 (7534.57.2) without setting the ETag
>
>
>
> GET / HTTP/1.1..Host: rtbstage.appspot.com (http://rtbstage.appspot.com)..User-Agent: Mozilla/5.0
> (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (
> KHTML, like Gecko) Version/5.1.7 Safari/534.57.2..Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8..Ca
> che-Control: max-age=0..Accept-Language: de-de..Accept-Encoding:
> gzip, deflate..Cookie: a=cookie:737060cd8c284d8af7ad3082f209
> 582d..Connection: keep-alive....
>
> The same request with firefox:
>
> GET / HTTP/1.1..Host: rtbstage.appspot.com (http://rtbstage.appspot.com)..User-Agent: Mozilla/5.0
> (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101
> Firefox/13.0.1..Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8..Accept-Language:
> de-de,de;q=0.8,en-u
> s;q=0.5,en;q=0.3..Accept-Encoding: gzip, deflate..Connection:
> keep-alive..Cookie: a=cookie:737060cd8c284d8af7ad3082f209582d..
> If-None-Match: "737060cd8c284d8af7ad3082f209582d"..Cache-Control:
> max-age=0....
>
I seem to be seeing behavior where if you request the file directly etag isn't observed, but if the file (like say, an image) is embedded in another page, then etags do seem to be used. Indeed odd.
>
> I think its not a problem of the/my go implementation.

I agree.

bay...@gmail.com

unread,
Jun 15, 2015, 10:40:29 AM6/15/15
to golan...@googlegroups.com, eli...@gmail.com, msch...@gmail.com, retep....@ymail.com
Hi,

I am still seeing this behaviour in safari 8.0.6.

Any updates?

Matt Silverlock

unread,
Jun 15, 2015, 7:09:59 PM6/15/15
to golan...@googlegroups.com, retep....@ymail.com, msch...@gmail.com, eli...@gmail.com, bay...@gmail.com
I suggest posting your code & your request/response headers (use the web inspector in Safari and post the headers from the Network tab).

Microsoft Office User

unread,
Jun 16, 2015, 7:17:48 AM6/16/15
to Matt Silverlock, golan...@googlegroups.com, retep....@ymail.com, msch...@gmail.com, eli...@gmail.com
I would but I’m not sure I trust Safari’s web inspector yet. I would like to use wireshark before I do.
Reply all
Reply to author
Forward
0 new messages