Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Fixed gzip-compressed HTTP requests ([#88](https://github.com/getsentry/github-workflows/pull/88))

## 2.12.0

### Fixes
Expand Down
3 changes: 3 additions & 0 deletions sentry-cli/integration-test/sentry-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import threading
import binascii
import json
import gzip

uri = urlparse(sys.argv[1] if len(sys.argv) > 1 else 'http://127.0.0.1:8000')
apiOrg = 'org'
Expand Down Expand Up @@ -135,6 +136,8 @@ def requestBody(self):
if self.command == "POST" and 'Content-Length' in self.headers:
length = int(self.headers['Content-Length'])
content = self.rfile.read(length)
if self.headers.get("Content-Encoding") == "gzip":
content = gzip.decompress(content)
try:
return content.decode("utf-8")
except:
Expand Down
24 changes: 24 additions & 0 deletions sentry-cli/integration-test/tests/action.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,28 @@ helloworld
$result.Envelopes()[0].Length | Should -Be 357
$result.Envelopes()[1].Length | Should -Be 84
}

It "collects gzip compressed envelopes" {
$result = Invoke-SentryServer {
Param([string]$url)
$ms = New-Object System.IO.MemoryStream
$gzip = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress)
$bytes = [System.Text.Encoding]::UTF8.GetBytes(@'
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"}
{"type":"attachment","length":10,"content_type":"text/plain","filename":"hello.txt"}
\xef\xbb\xbfHello\r\n
{"type":"event","length":41,"content_type":"application/json","filename":"application.log"}
{"message":"hello world","level":"error"}
'@)
$gzip.Write($bytes, 0, $bytes.Length)
$gzip.Close()
$body = $ms.ToArray()
$ms.Close()
Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body $body -Headers @{ "Content-Encoding" = "gzip" }
}

Should -ActualValue $result.HasErrors() -BeFalse
$result.Envelopes().Length | Should -Be 1
$result.Envelopes()[0].Length | Should -Be 357
}
}
Loading