Skip to content

Commit 1ba210a

Browse files
authored
fix: attachments transport (#80)
* fix: attachments transport * chore: changelog
1 parent 4ff3184 commit 1ba210a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Drop support for PowerShell 7.2 and 7.3 ([#71](https://github.com/getsentry/sentry-powershell/pull/71))
88

9+
### Fixes
10+
11+
- Attachments support regression introduced in v0.2.0 ([#80](https://github.com/getsentry/sentry-powershell/pull/80))
12+
913
### Features
1014

1115
- Add support for PowerShell 7.5 ([#76](https://github.com/getsentry/sentry-powershell/pull/76))

modules/Sentry/private/SynchronousTransport.ps1

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class SynchronousTransport : Sentry.Http.HttpTransportBase, Sentry.Extensibility
1111
SynchronousTransport([Sentry.SentryOptions] $options) : base($options)
1212
{
1313
$this.logger = $options.DiagnosticLogger
14-
if ($null -eq $this.logger) {
14+
if ($null -eq $this.logger)
15+
{
1516
$this.logger = Get-Variable -Scope script -Name SentryPowerShellDiagnosticLogger -ValueOnly -ErrorAction SilentlyContinue
1617
}
1718

@@ -42,16 +43,13 @@ class SynchronousTransport : Sentry.Http.HttpTransportBase, Sentry.Extensibility
4243
$this.SerializeToStream.Invoke($request.Content, @($memoryStream, $null, $cancellationToken))
4344
$memoryStream.Position = 0
4445

45-
$reader = New-Object System.IO.StreamReader($memoryStream)
46-
$content = $reader.ReadToEnd()
47-
$reader.Close()
48-
49-
if ($null -ne $this.logger) {
50-
$this.logger.Log([Sentry.SentryLevel]::Debug, 'Sending content synchronously, Content-Length: {0}', $null, $content.Length)
46+
if ($null -ne $this.logger)
47+
{
48+
$this.logger.Log([Sentry.SentryLevel]::Debug, 'Sending content synchronously, Content-Length: {0}', $null, $memoryStream.Length)
5149
}
5250

5351
$ProgressPreference = 'SilentlyContinue'
54-
$psResponse = Invoke-WebRequest -Uri $request.RequestUri -Method $request.Method.Method -Headers $headers -Body $content -UseBasicParsing
52+
$psResponse = Invoke-WebRequest -Uri $request.RequestUri -Method $request.Method.Method -Headers $headers -Body $memoryStream -UseBasicParsing
5553

5654
$response = [System.Net.Http.HttpResponseMessage]::new($psResponse.StatusCode)
5755
$contentType = $psResponse.Headers['Content-Type']

0 commit comments

Comments
 (0)