简体   繁体   中英

C# HttpClient response unreadable content

I solved my problem by remove the header name/value: Accept-Encoding: gzip, deflate

I'm using HttpClient class to make request to Facebook. I make to request to facebook.

The first is to homepage: The result is the HTML code of Facebook homepage.

The second is login to facebook ( with headers and request body ): The result of this requert is unreadable. It's "��|ko�Hv���.�c��-��jya[v�n��d�� �D�IJ(�&�����rq� ��_���`�/I��X �o�|���o�s��"

If I login failed, the result must be some readable string. What am I encountering? What should i do to resolve this problem ?

You need to check if the content is gzipped or not and deflate it dynamically. Otherwise, just remove the Accept-Encoding: gzip, deflate as you mentioned in your original question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM