@@ -222,8 +222,27 @@ func (s *httpServer) doPUB(w http.ResponseWriter, req *http.Request, ps httprout
222222 }
223223 }
224224
225+ var isSnappy , isDeflate bool
226+ if value , exist := req .Header ["Content-Encoding" ]; exist {
227+ for _ , encoding := range value {
228+ if encoding == "snappy" {
229+ isSnappy = true
230+ }
231+
232+ if encoding == "deflate" {
233+ isDeflate = true
234+ }
235+ }
236+ }
237+
238+ if isSnappy && isDeflate {
239+ return nil , http_api.Err {400 , "INVALID_CONTENT_ENCODING" }
240+ }
241+
225242 msg := NewMessage (topic .GenerateID (), body )
226243 msg .deferred = deferred
244+ msg .snappyCompressed = isSnappy
245+ msg .deflateCompressed = isDeflate
227246 err = topic .PutMessage (msg )
228247 if err != nil {
229248 return nil , http_api.Err {503 , "EXITING" }
@@ -248,6 +267,23 @@ func (s *httpServer) doMPUB(w http.ResponseWriter, req *http.Request, ps httprou
248267 return nil , err
249268 }
250269
270+ var isSnappy , isDeflate bool
271+ if value , exist := req .Header ["Content-Encoding" ]; exist {
272+ for _ , encoding := range value {
273+ if encoding == "snappy" {
274+ isSnappy = true
275+ }
276+
277+ if encoding == "deflate" {
278+ isDeflate = true
279+ }
280+ }
281+ }
282+
283+ if isSnappy && isDeflate {
284+ return nil , http_api.Err {400 , "INVALID_CONTENT_ENCODING" }
285+ }
286+
251287 // text mode is default, but unrecognized binary opt considered true
252288 binaryMode := false
253289 if vals , ok := reqParams ["binary" ]; ok {
@@ -302,6 +338,11 @@ func (s *httpServer) doMPUB(w http.ResponseWriter, req *http.Request, ps httprou
302338 }
303339 }
304340
341+ for _ , msg := range msgs {
342+ msg .snappyCompressed = isSnappy
343+ msg .deflateCompressed = isDeflate
344+ }
345+
305346 err = topic .PutMessages (msgs )
306347 if err != nil {
307348 return nil , http_api.Err {503 , "EXITING" }
0 commit comments