                   (response->class-info-map
                    test-response-after-all-flush))
                "unexpected body for test response")))))))
+
+(deftest ^:integration
+         not-modified-returned-for-environment-class-info-request-with-gzip-tag
+  (testing (str "SERVER-1153 - when the webserver gzips the response "
+                "containing environment_classes etag, the next request "
+                "roundtripping that etag returns an HTTP 304 (Not Modified)")
+    (let [expected-etag "abcd1234"
+          body-length 200000
+          jruby-service (reify jruby/JRubyPuppetService
+                          (get-environment-class-info-tag [_ _]
+                            expected-etag))
+          app (->
+               (fn [_]
+                 (master-core/response-with-etag
+                  (apply str (repeat body-length "a"))
+                  expected-etag))
+               (master-core/wrap-with-etag-check jruby-service))]
+      (jetty9/with-test-webserver
+       app
+       port
+       (let [request-url (str "http://localhost:" port)
+             initial-response (http-client/get request-url {:as :text})
+             response-tag (response-etag initial-response)
+             response-with-tag (http-client/get
+                                request-url
+                                {:headers {"If-None-Match" response-tag}
+                                 :as :text})]
+         (is (= 200 (:status initial-response))
+             "response for initial request is not 'successful'")
+         (is (= (get-in initial-response [:headers "content-encoding"]) "gzip")
+             "response from initial request was not gzipped")
+         (is (= body-length (count (:body initial-response)))
+             "unexpected response body length for initial response")
+         (is (not (empty? response-tag))
+             "no etag returned for initial response")
+         (is (= 304 (:status response-with-tag))
+             (str "request with prior etag did not return http 304 (not "
+                  "modified) status code"))
+         (is (empty? (:body response-with-tag))
+             "unexpected body for request with prior etag"))))))

        "environment="
        env)
   testutils/ssl-request-options))

(deftest ^:integration environment-classes-integration-test
  (bootstrap/with-puppetserver-running app

                                          "default_source" "\"is foo\""}]}]}]
                                    "name" "production"}
         initial-response (get-env-classes "production")
         initial-etag (response-etag initial-response)]
     (testing "initial fetch of environment_classes info is good"
       (is (= 200 (:status initial-response))
