File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,10 @@ def text(self) -> str:
435
435
return self ._cached
436
436
raise RuntimeError ("Cannot access text after getting content or json" )
437
437
438
- if self .headers ["content-encoding" ] == "gzip" :
438
+ if (
439
+ "content-encoding" in self .headers
440
+ and self .headers ["content-encoding" ] == "gzip"
441
+ ):
439
442
raise ValueError (
440
443
"Content-encoding is gzip, data cannot be accessed as json or text. "
441
444
"Use content property to access raw bytes."
@@ -456,7 +459,10 @@ def json(self) -> Any:
456
459
if not self ._raw :
457
460
self ._raw = _RawResponse (self )
458
461
459
- if self .headers ["content-encoding" ] == "gzip" :
462
+ if (
463
+ "content-encoding" in self .headers
464
+ and self .headers ["content-encoding" ] == "gzip"
465
+ ):
460
466
raise ValueError (
461
467
"Content-encoding is gzip, data cannot be accessed as json or text. "
462
468
"Use content property to access raw bytes."
You can’t perform that action at this time.
0 commit comments