Skip to content

Commit d2bdc9a

Browse files
authored
fix: gzip compressed envelopes (#88)
* fix: gzip compressed envelopes * Update CHANGELOG.md
1 parent cd1c852 commit d2bdc9a

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Fixed gzip-compressed HTTP requests ([#88](https://github.com/getsentry/github-workflows/pull/88))
8+
39
## 2.12.0
410

511
### Fixes

sentry-cli/integration-test/sentry-server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import threading
99
import binascii
1010
import json
11+
import gzip
1112

1213
uri = urlparse(sys.argv[1] if len(sys.argv) > 1 else 'http://127.0.0.1:8000')
1314
apiOrg = 'org'
@@ -135,6 +136,8 @@ def requestBody(self):
135136
if self.command == "POST" and 'Content-Length' in self.headers:
136137
length = int(self.headers['Content-Length'])
137138
content = self.rfile.read(length)
139+
if self.headers.get("Content-Encoding") == "gzip":
140+
content = gzip.decompress(content)
138141
try:
139142
return content.decode("utf-8")
140143
except:

sentry-cli/integration-test/tests/action.Tests.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,28 @@ helloworld
7272
$result.Envelopes()[0].Length | Should -Be 357
7373
$result.Envelopes()[1].Length | Should -Be 84
7474
}
75+
76+
It "collects gzip compressed envelopes" {
77+
$result = Invoke-SentryServer {
78+
Param([string]$url)
79+
$ms = New-Object System.IO.MemoryStream
80+
$gzip = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress)
81+
$bytes = [System.Text.Encoding]::UTF8.GetBytes(@'
82+
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"}
83+
{"type":"attachment","length":10,"content_type":"text/plain","filename":"hello.txt"}
84+
\xef\xbb\xbfHello\r\n
85+
{"type":"event","length":41,"content_type":"application/json","filename":"application.log"}
86+
{"message":"hello world","level":"error"}
87+
'@)
88+
$gzip.Write($bytes, 0, $bytes.Length)
89+
$gzip.Close()
90+
$body = $ms.ToArray()
91+
$ms.Close()
92+
Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body $body -Headers @{ "Content-Encoding" = "gzip" }
93+
}
94+
95+
Should -ActualValue $result.HasErrors() -BeFalse
96+
$result.Envelopes().Length | Should -Be 1
97+
$result.Envelopes()[0].Length | Should -Be 357
98+
}
7599
}

0 commit comments

Comments
 (0)