开发者

Why does HTTP::Response::decoded_content sometimes return undef even when content() returns data? [closed]

开发者 https://www.devze.com 2022-12-18 11:12 出处:网络
Th开发者_StackOverflowis question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is
Th开发者_StackOverflowis question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I've used LWP capability to handle gzip encoded content as described here, but in some cases I randomly get unexpected results at least for the one website I've tested: $response->decoded_content could become undefined while $response->content still returns original gzip encoded response. Tried even without internal charset decoding (decoded_content(charset => 'none')) with the same result.


This doesn't directly answer your question, but when I encounter things like this I look at the source of the module to see what it is doing and debug the code just like any other code. Looking at the decoded_content method in HTTP::Message shows you exactly what it is expecting. Check that your response has all of the things it expects.


Is the server perhaps not properly setting Content-Encoding in the response? In any case, take a look at the headers for both working and non-working responses and look for significant differences.

0

精彩评论

暂无评论...
验证码 换一张
取 消