test-bug-599725-response-headers.sjs 735 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. function handleRequest(request, response)
  6. {
  7. var Etag = '"4c881ab-b03-435f0a0f9ef00"';
  8. var IfNoneMatch = request.hasHeader("If-None-Match")
  9. ? request.getHeader("If-None-Match")
  10. : "";
  11. var page = "<!DOCTYPE html><html><body><p>hello world!</p></body></html>";
  12. response.setHeader("Etag", Etag, false);
  13. if (IfNoneMatch == Etag) {
  14. response.setStatusLine(request.httpVersion, "304", "Not Modified");
  15. }
  16. else {
  17. response.setHeader("Content-Type", "text/html", false);
  18. response.setHeader("Content-Length", page.length + "", false);
  19. response.write(page);
  20. }
  21. }