Home Backend Development PHP Tutorial php使用curl出现Expect:100-continue解决方法_php技巧

php使用curl出现Expect:100-continue解决方法_php技巧

May 16, 2016 pm 08:22 PM
curl php Solution

本文实例讲述了php使用curl出现Expect:100-continue解决方法。分享给大家供大家参考。具体如下:

使用curl POST数据时,如果POST的数据大于1024字节,curl并不会直接就发起POST请求。而是会分两步。

1.发送一个请求,header中包含一个Expect:100-continue,询问Server是否愿意接受数据。
2.接受到Server返回的100-continue回应后,才把数据POST到Server。

这个是libcurl定义的,具体可以查看相关描述:http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3

于是这样就会出现一个问题。并不是所有的Server都会回应100-continue的。例如lighttpd,会返回"417 Expectation Fail",会造成逻辑错误。

解决方法如下,就是发送请求时,header中包含一个空的Expect。

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:")); 
Copy after login

希望本文所述对大家的php程序设计有所帮助。

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

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
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 尊渡假赌尊渡假赌尊渡假赌

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)

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? Apr 02, 2025 am 07:15 AM

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

Why do I get ValueError: too many values ​​to unpack (expected 2) error when using pyecharts' Map? How to solve this problem? Why do I get ValueError: too many values ​​to unpack (expected 2) error when using pyecharts' Map? How to solve this problem? Apr 01, 2025 pm 07:42 PM

The reason and solution to the valueError:toomyvalueestounpack(expected2) error when using pyecharts' Map...

Python 3.6 loading pickle file error ModuleNotFoundError: What should I do if I load pickle file '__builtin__'? Python 3.6 loading pickle file error ModuleNotFoundError: What should I do if I load pickle file '__builtin__'? Apr 02, 2025 am 06:27 AM

Loading pickle file in Python 3.6 environment error: ModuleNotFoundError:Nomodulenamed...

The Python subprocess module fails to execute the wmic datafile command. How to solve it? The Python subprocess module fails to execute the wmic datafile command. How to solve it? Apr 01, 2025 pm 08:48 PM

Use Python's subprocess module to execute wmic...

What should I do if the '__builtin__' module is not found when loading the Pickle file in Python 3.6? What should I do if the '__builtin__' module is not found when loading the Pickle file in Python 3.6? Apr 02, 2025 am 07:12 AM

Error loading Pickle file in Python 3.6 environment: ModuleNotFoundError:Nomodulenamed...

How to efficiently read Windows system logs and get only information from the last few days? How to efficiently read Windows system logs and get only information from the last few days? Apr 01, 2025 pm 11:21 PM

Efficient reading of Windows system logs: Reversely traverse Evtx files When using Python to process Windows system log files (.evtx), direct reading will be from the earliest...

See all articles