本文介绍了cURL请求从PHP的Unix套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从php

curl --unix-socket /var/run/docker.sock http:/images/json

我去过可用于 curl_setopt 的选项,但找不到任何选项 - unix-socket

我从上面curl调用回答。

编辑

从博客,我们可以使用 CURLOPT_UNIX_SOCKET_PATH

I went through this list of options available for curl_setopt but couldn't find any option related to above --unix-socket
I got above curl call from this answer.

From this blog, can we somehow use CURLOPT_UNIX_SOCKET_PATH option in php ?

推荐答案

我不知道这是否有效,但是你试过fsockopen吗?

I don't know if this would work, but have you tried fsockopen?

这样可能的工作,我没有尝试过。

Something like this might work, I haven't tried it.

$fs = fsockopen('/var/run/docker.sock');

fwrite($fs, "GET / HTTP/1.1\r\nHOST: http:/images/json\r\n\r\n");

    while (!feof($fs)) {
        print fread($fs,256);
    }

这篇关于cURL请求从PHP的Unix套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:15