服务器有时会返回分块传输编码

编程入门 行业动态 更新时间:2024-10-15 20:24:36
本文介绍了服务器有时会返回分块传输编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在构建一个 REST API.. 有时服务器会使用分块传输编码返回响应?这是为什么?!

I'm building a REST API.. Sometimes the server returns the response with chunked transfer encoding? Why is that?!

为什么服务器不能总是以相同的编码返回响应?

Why can't the server always return the response in the same encoding?

问题是当数据以分块形式返回时,我不知道如何读取数据!?

The problem is that I don't know how to read the data when its returned as chunked!?

需要moore downvotes...到breeeath...

neeed moore downvotes... to breeeath...

推荐答案

假设您的服务器使用 Apache,这是预期行为.您可以通过将此行放在 .htaccess 文件中来禁用它:

Assuming your server is using Apache, this is expected behaviour. You can disable it by putting this line in your .htaccess file:

SetEnv downgrade-1.0

但是,您应该考虑修改您的阅读代码以仅支持不同的内容编码.您使用什么库来发出 HTTP 请求?任何合理的 HTTP 库都可以处理分块请求.如果您的请求代码是用 PHP 编写的,请使用 curl.http://php/manual/en/book.curl.php

However, you should consider modifying your reading code to just support different content encodings. What library are you using to make the HTTP request? Any reasonable HTTP library can handle chunked requests. If your requesting code is written in PHP, use curl. http://php/manual/en/book.curl.php

这篇关于服务器有时会返回分块传输编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 15:19:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/942194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有时会   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!