Search code examples
javahttphttpclientetagquoting

Java: routine for proper ETag quoting?


Is there any method that already implements proper ETag quoting for http headers?

As pointed out in Syntax for ETag? the proper way is not as trivial as putting double quotes around it.

Couldn't find anything obvious.


Solution

  • That's kind of misleading. The quotes are an integral part of the ETag, so there's no transition from "unquoted ETag" to "quoted ETag".

    If what you're after is a way to include characters not allowed in ETags, you'll just to invent a custom escaping syntax. Which one doesn't matter, because your server is producing and consuming them, and for clients they are fully opaque.