Skip to content

Commit 8ae9dc6

Browse files
committed
fix(client): guard compressed DPS payload encoding
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 6e31b33 commit 8ae9dc6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Http/NfseClient.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,14 @@ public function cancel(string $chaveAcesso, string $motivo): bool
103103
*/
104104
private function post(string $path, string $xmlPayload): array
105105
{
106+
$compressedPayload = gzencode($xmlPayload);
107+
108+
if ($compressedPayload === false) {
109+
throw new NetworkException('Failed to compress DPS XML payload before transmission.');
110+
}
111+
106112
$payload = json_encode([
107-
'dpsXmlGZipB64' => base64_encode(gzencode($xmlPayload)),
113+
'dpsXmlGZipB64' => base64_encode($compressedPayload),
108114
], JSON_THROW_ON_ERROR);
109115

110116
$context = stream_context_create([

0 commit comments

Comments
 (0)