PHP CURL Memory leak Problem Solving method

Source: Internet
Author: User
Tags curl http request

This article mainly introduces the PHP CURL memory leak Problem Solving method, Crul access to HTTPS site for a long time memory leak problem, this article after repeated debugging found a solution, the need for friends can refer to the

Phpcurl use Privoxy proxy to access https://www.google.com/search?q=xxx

Curl configuration is bland, long run found a serious problem, memory leak! Both single-threaded and multithreading are unavoidable! is curl to visit HTTPS site with bug!

Memory leaks can be found using the Linux top command, Memory_get_usage () with PHP functions.

After repeated debugging to find a solution, the Curl configuration adds the following to solve the problem:

The code is as follows:

[Curlopt_httpproxytunnel] = true;

[Curlopt_ssl_verifypeer] = false;

[Curlopt_ssl_verifyhost] = false;

Curlopt_httpproxytunnel specific instructions on the StackOverflow, directly affixed to the original:

Without Curlopt_httpproxytunnel

Without curlopt_httpproxytunnel:you just use the proxy address/port as a destination of your HTTP request. The proxy would read the HTTP headers of your query, forward your request to the destination (with your HTTP headers) and T Hen write the response to you.

Example steps:

1) HTTP get/index.html sent to 1.1.1.1 (proxy)

2) 1.1.1.1 receive request and parse header for getting the final destination of the your HTTP request.

3) 1.1.1.1 forward your query and headers to www.site.com (destination in request headers).

4) 1.1.1.1 write back to your response receive from www.site.com

With Curlopt_httpproxytunnel

With curlopt_httpproxytunnel:you ask the proxy to open a direct binary connection (like HTTPS, called a TCP tunnel) dire ctly to your destination by doing a CONNECT HTTP request. When the ' tunnel is OK, the proxy write your back a http/1.1 Connection established. When it received your browser start to query the destination directly:the proxy does not parse HTTP headers and Theoreti Cally does not read tunnel datas, it just forward it, thats why it is called a tunnel!

Example steps:

1) HTTP CONNECT sent to 1.1.1.1

2) 1.1.1.1 receive HTTP connect and get the Ip/port of your final destination (header field of HTTP connect).

3) 1.1.1.1 open a TCP Socket by doing a TCP handshake to your destination 2.22.63.73:80 (Ip/port of www.site.com).

4 1.1.1.1 make a tunnel by piping your TCP sockets to the TCP sockets opened to 2.22.63.73:80and then write your back HTTP/1. 1 Connection established witch means that your client can now make your query throw the TCP tunnel (TCP Datas received 'll is transmited directly to server and vice versa).

Http://stackoverflow.com/questions/12288956/what-is-the-curl-option-curlopt-httpproxytunnel-means

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.