Skip to content

Commit

Permalink
Merge pull request #111 from codex-team/sentry-compression
Browse files Browse the repository at this point in the history
Support gzip encoding detection
  • Loading branch information
n0str authored Dec 26, 2024
2 parents d35a280 + 3197ee1 commit 4009bfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/server/errorshandler/handler_sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ func (handler *Handler) HandleSentry(ctx *fasthttp.RequestCtx) {
// parse incoming get request params
sentryKey := ctx.QueryArgs().Peek("sentry_key")
if sentryKey == nil {
log.Warnf("Incoming request with deprecated sentry_key parameter")

// check that X-Sentry-Auth header is available
auth := ctx.Request.Header.Peek("X-Sentry-Auth")
if auth == nil {
Expand All @@ -50,15 +48,17 @@ func (handler *Handler) HandleSentry(ctx *fasthttp.RequestCtx) {

sentryEnvelopeBody := ctx.PostBody()

// todo: add check of gzip header
if sentryKey == nil {
contentEncoding := string(ctx.Request.Header.Peek("Content-Encoding"))
if contentEncoding == "gzip" {
sentryEnvelopeBody, err = decompressGzipString(sentryEnvelopeBody)
if err != nil {
log.Warnf("Failed to decompress gzip body: %s", err)
sendAnswerHTTP(ctx, ResponseMessage{Code: 400, Error: true, Message: "Failed to decompress gzip body"})
return
}
log.Debugf("Decompressed body: %s", sentryEnvelopeBody)
} else {
log.Debugf("Body: %s", sentryEnvelopeBody)
}

projectId, ok := handler.AccountsMongoDBClient.ValidTokens[hawkToken]
Expand Down

0 comments on commit 4009bfd

Please sign in to comment.