chia7712 commented on code in PR #757:
URL: https://github.com/apache/yunikorn-core/pull/757#discussion_r1520085690


##########
pkg/webservice/handlers.go:
##########
@@ -1216,3 +1227,40 @@ func getStream(w http.ResponseWriter, r *http.Request) {
                }
        }
 }
+
+func checkHeader(h http.Header, key string, value string) bool {

Review Comment:
   Should we return error if users use unsupported compression?



##########
pkg/webservice/handlers.go:
##########
@@ -1216,3 +1227,40 @@ func getStream(w http.ResponseWriter, r *http.Request) {
                }
        }
 }
+
+func checkHeader(h http.Header, key string, value string) bool {
+       values := h.Values(key)
+       for _, v := range values {
+               if v == value {
+                       return true
+               }
+       }
+       return false
+}
+
+func compress(w http.ResponseWriter, data any) {
+       response, err := json.Marshal(data)
+       if err != nil {
+               buildJSONErrorResponse(w, err.Error(), 
http.StatusInternalServerError)
+               return
+       }
+
+       var compressedData bytes.Buffer
+       writer := gzip.NewWriter(&compressedData)
+       _, err = writer.Write(response)
+       if err != nil {
+               buildJSONErrorResponse(w, err.Error(), 
http.StatusInternalServerError)

Review Comment:
   Should we close the `writer` here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to