Server-side PHP Build Curl command line

Source: Internet
Author: User
Log the request to log, in order to facilitate subsequent troubleshooting, in PHP to call a method, the implementation of the curl string can be recorded to facilitate the replication request.

Java code

$value) {                if (substr ($name, 0, 5) = = ' Http_ ') {                    $headers [Str_replace (', '-', Ucwords (Strtolower (' _ ', ', substr ($name, 5)))])] = $value;                }}        }        foreach ($headers as $key = + $value) {            if ($key = = ' accept-encoding ')  $value = Str_replace (' gzip, ', ' ', $value);            $curlCommand. = '-h '. $key. ':' . $value. '"';        }        return $curlCommand;    } catch (Exception $e) {        return $e->getmessage ();}    } Echo Getcurlcommand ();

eg

Java code

Curl "HTTP://LOCALHOST/OTHER/SERVERINFO.PHP?DD=DDD"-H "host:localhost"-H "connection:keep-alive"-H "Cache-control: Max-age=0 "-H" accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 "-H" User-Agent: mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/43.0.2357.132 safari/537.36 "-H" dnt:1 "-H" accept-encoding:deflate , SDCH "-H" accept-language:zh-cn,zh;q=0.8,en;q=0.6 "-H" cookie:name=shikiliu; Email=xishizhaohua%40qq.com "

Related articles:

To view the request response time method using the Curl command

Linux System Curl Command

Server-side PHP Build Curl command line

  • 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.