Home php教程 php手册 RCA:未注意Curl-library Post 1024以上字节时的HTTP/1.1特性导致 HessianPHP 传

RCA:未注意Curl-library Post 1024以上字节时的HTTP/1.1特性导致 HessianPHP 传

Jun 13, 2016 am 11:31 AM
http post rca lead to not yet Notice characteristic of

先列出 HessianPHP 的错误提示:


基础知识背景: 1)“Expect: 100-continue”的来龙去脉:     HTTP/1.1 协议里设计 100 (Continue) HTTP 状态码的的目的是,在客户端发送 Request Message 之前,HTTP/1.1 协议允许客户端先判定服务器是否愿意接受客户端发来的消息主体(基于 Request Headers)。     即,Client 和 Server 在 Post (较大)数据之前,允许双方“握手”,如果匹配上了,Client 才开始发送(较大)数据。     这么做的原因是,如果客户端直接发送请求数据,但是服务器又将该请求拒绝的话,这种行为将带来很大的资源开销。       协议对 HTTP/1.1 clients 的要求是:
 的头域!  
2)libcurl 发送大于1024字节数据时启用“Expect:100-continue‘特性:

1. 发送一个请求,包含一个 "Expect: 100-continue" 头域,询问 Server 是否愿意接收数据; 2. 接收到 Server 返回的 100-continue 应答以后,才把数据 POST 给 Server;

 

    zxgfa 在 2012年补充说:

(郑昀注1:lighttpd 1.4 版本有此严重问题,于1.5版本修复。 郑昀注2:Resin 于 3.0.5 版本增加了对 Expect: 100-continue 的支持。)

 

3)PHP Curl-library 可以主动封禁此特性:     有人在 PHP手册::curl_setopt 下留言说:     PHP curl 遵从 libcurl 的特性。由于不是所有 web servers 都支持这个特性,所以会产生各种各样的错误。如果你遇到了,可以用下面的命令封禁"Expect"头域:     <span class="html"><span class="default">    <?php </span></span></span> <span class="html"><span class="default">    curl_setopt</span><span class="keyword">(</span><span class="default">$ch</span><span class="keyword">,<span class="Apple-converted-space"> </span></span><span class="default">CURLOPT_HTTPHEADER</span><span class="keyword">, array(</span><span class="string">'Expect:'</span><span class="keyword">));<br></span><span class="default">    ?><br></span><span pooy><br></span></span>         图1 You can convince PHP's curl backend to stop doing the 100-continue-thing by setting an explicit request header  
其他知识背景:
  • 根据 HessianTransport 代码所述,”Hessian request using the CURL library“。

问题现象:
,hessian 报错“CURL transport error: transfer closed with outstanding read data remaining”。
  解决: 修改hessian中 CURLOPT 项: CURLOPT_HTTPHEADER => array("Content-Type: application/binary")  改为 CURLOPT_HTTPHEADER => array("Content-Type: application/binary","Expect:") 
p.s.:     有人认为改为 HTTP/1.0 协议即可绕过这个 100-continue 问题,但这只是工程师不愿意搞清楚原理而示弱的表现。   参考资源: 1)2011,Laruence,Expect:100-continue; 2)PHP手册,If you are doing a POST, and the content length is 1,025 or greater; 3)HTTP 1.1 RFC,Use of the 100 (Continue) Status; 4)stackoverflow,2009,PHP HTTP POST fails when cURL data > 1024; 5)zxgfa,2012,libcurl的使用问题“Expect100-continue”; 6)lighttpd,2009,'Expect' header gives HTTP error 417;
赠图几枚: 请施主拿去: 360度后空翻开球: 360无死角:  

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

Detailed explanation of the role of .ibd files in MySQL and related precautions Detailed explanation of the role of .ibd files in MySQL and related precautions Mar 15, 2024 am 08:00 AM

Detailed explanation of the role of .ibd files in MySQL and related precautions MySQL is a popular relational database management system, and the data in the database is stored in different files. Among them, the .ibd file is a data file in the InnoDB storage engine, used to store data and indexes in tables. This article will provide a detailed analysis of the role of the .ibd file in MySQL and provide relevant code examples to help readers better understand. 1. The role of .ibd files: storing data: .ibd files are InnoDB storage

How to implement HTTP streaming using C++? How to implement HTTP streaming using C++? May 31, 2024 am 11:06 AM

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

How to solve HTTP 503 error How to solve HTTP 503 error Mar 12, 2024 pm 03:25 PM

Solution: 1. Retry: You can wait for a period of time and try again, or refresh the page; 2. Check the server load: Check the server's CPU, memory and disk usage. If the capacity limit is exceeded, you can try to optimize the server configuration or increase the capacity. Server resources; 3. Check server maintenance and upgrades: You can only wait until the server returns to normal; 4. Check network connection: Make sure the network connection is stable, check whether the network device, firewall or proxy settings are correct; 5. Ensure cache or CDN configuration Correct; 6. Contact the server administrator, etc.

PHP code example: How to use POST to pass parameters and implement page jumps PHP code example: How to use POST to pass parameters and implement page jumps Mar 07, 2024 pm 01:45 PM

Title: PHP code example: How to use POST to pass parameters and implement page jumps In web development, it often involves the need to pass parameters through POST and process them on the server side to implement page jumps. PHP, as a popular server-side scripting language, provides a wealth of functions and syntax to achieve this purpose. The following will introduce how to use PHP to implement this function through a practical example. First, we need to prepare two pages, one to receive POST requests and process parameters

How to implement PHP to jump to the page and carry POST data How to implement PHP to jump to the page and carry POST data Mar 22, 2024 am 10:42 AM

PHP is a programming language widely used in website development, and page jumps and carrying POST data are common requirements in website development. This article will introduce how to implement PHP page jump and carry POST data, including specific code examples. In PHP, page jumps are generally implemented through the header function. If you need to carry POST data during the jump process, you can do it through the following steps: First, create a page containing a form, where the user fills in the information and clicks the submit button. Acti in the form

How to configure RCA universal remote using code? How to configure RCA universal remote using code? Feb 21, 2024 am 10:03 AM

You can use the RCA universal remote to simplify remote control management. With various models, you can control up to eight devices, eliminating the need for multiple remotes and reducing clutter. Be patient in programming the remote and follow the simple steps provided. So, if you want to configure an RCA universal remote using codes, this article is for you. How to Configure an RCA Universal Remote Using Codes To configure an RCA Universal remote using codes, use one of the methods below. Programming the RCA Universal Remote Using the Automatic Programming Method Programming the RCA Universal Remote Using Direct Code Let’s talk about it in detail. 1] To program the RCA universal remote control using the automatic programming method, we must first use a simple

Are there any class-like object-oriented features in Golang? Are there any class-like object-oriented features in Golang? Mar 19, 2024 pm 02:51 PM

There is no concept of a class in the traditional sense in Golang (Go language), but it provides a data type called a structure, through which object-oriented features similar to classes can be achieved. In this article, we'll explain how to use structures to implement object-oriented features and provide concrete code examples. Definition and use of structures First, let's take a look at the definition and use of structures. In Golang, structures can be defined through the type keyword and then used where needed. Structures can contain attributes

See all articles