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:
435435 return self ._cached
436436 raise RuntimeError ("Cannot access text after getting content or json" )
437437
438- if self .headers ["content-encoding" ] == "gzip" :
438+ if (
439+ "content-encoding" in self .headers
440+ and self .headers ["content-encoding" ] == "gzip"
441+ ):
439442 raise ValueError (
440443 "Content-encoding is gzip, data cannot be accessed as json or text. "
441444 "Use content property to access raw bytes."
@@ -456,7 +459,10 @@ def json(self) -> Any:
456459 if not self ._raw :
457460 self ._raw = _RawResponse (self )
458461
459- if self .headers ["content-encoding" ] == "gzip" :
462+ if (
463+ "content-encoding" in self .headers
464+ and self .headers ["content-encoding" ] == "gzip"
465+ ):
460466 raise ValueError (
461467 "Content-encoding is gzip, data cannot be accessed as json or text. "
462468 "Use content property to access raw bytes."
You can’t perform that action at this time.
0 commit comments