我试图通过HTTPS获取流的内容,但我必须通过HTTP代理.我不想使用cURL,而是使用fopen和context参数.
问题是,我无法通过HTTPS工作(HTTP工作正常).
这DOES NOT工作:
$stream = stream_context_create(Array("http" => Array("method" => "GET",
"timeout" => 20,
"proxy" => "tcp://my-proxy:3128",
'request_fulluri' => True
)));
echo file_get_contents('https://my-stream', false, $context);
Run Code Online (Sandbox Code Playgroud)
这DOES作品(卷曲):
$url = 'https://my-stream';
$proxy = 'my-proxy:3128';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
Run Code Online (Sandbox Code Playgroud)
有人知道第一段代码有什么问题吗?如果它与cURL一起使用,必须有一种方法使它适用于上下文.我试图将上下文选项更改为一堆不同的值,但没有运气.
任何帮助将不胜感激 !
谢谢.
在我的Play 2应用程序中,我在java.net.URL,Bee Client上调用Scala包装器.根据文档,java.net.URL支持代理,但我找不到有关如何以及如何为环境变量设置的详细信息.
我试过,没有成功,
export proxySet=true
export proxyHost=my-proxy-server
export proxyPort=1080
Run Code Online (Sandbox Code Playgroud)
任何帮助都感激不尽.
更新: 在进一步挖掘之后,它们不是环境变量,而是Rick指出的JVM命令行参数.但是,我也试过以下也没有成功
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=my-proxy-server -Dhttp.proxyPort=1080"
sbt -Dhttp.proxyHost=my-proxy-server -Dhttp.proxyPort=1080 test
Run Code Online (Sandbox Code Playgroud)
请注意,我将参数传递给sbt test.
我想知道数据包嗅探器的原理.他们如何捕获其他应用程序的数据包?
我一直在考虑这个问题.我有一个理论.这与代理服务器的工作方式有关吗?当使用某些特殊API时,所有本地应用程序都会将其数据包发送到指定的ip而不是原始数据包.数据包嗅探器接收并复制,最后将它们发送回原始目的地.是对的吗?
你能解释一下数据包嗅探器是如何工作的吗?提前谢谢你的帮助.
如果我的服务器使用Cloudflare,我如何获得使用代理的访问者的Real IP?
到目前为止,如果访问者在不使用代理的情况下打开我的服务器(使用cloudflare),这将起作用
isset($_SERVER["HTTP_CF_CONNECTING_IP"]) ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];
Run Code Online (Sandbox Code Playgroud) 我正在尝试在现有的spring项目中配置一个建议.以下配置适用于单个程序包,但是当切入点表达式尝试在所有程序包上应用该通知时,它会给出以下错误.
我的配置:
<aop:config>
<aop:pointcut id="loggingPointcut" expression="execution(* com.abc.businessprocess.operation..*.execute(..))" />
<aop:advisor id="methodLoggingAdvisor" advice-ref="methodLoggingAdvice" pointcut-ref="loggingPointcut" />
</aop:config>
Run Code Online (Sandbox Code Playgroud)
我也尝试了注释,但它给出了相同的错误.即使在使用它给出相同的错误后,我也尝试使用CGLIB.
错误:
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy12 implementing com.fmr.ast.common.businessprocess.util.Timeable,com.fmr.ast.common.businessprocess.operation.Operation,com.fmr.commons.taskmanager.core.Task,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.fmr.ips.businessprocess.operation.goalsetup.GetLeveledIRGExpInc] for property 'getRawDetailedLeveledExpInc'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy12 implementing com.fmr.ast.common.businessprocess.util.Timeable,com.fmr.ast.common.businessprocess.operation.Operation,com.fmr.commons.taskmanager.core.Task,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.fmr.ips.businessprocess.operation.goalsetup.GetLeveledIRGExpInc] for property 'getRawDetailedLeveledExpInc': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 33 more
Caused by: java.lang.IllegalArgumentException: Cannot convert …Run Code Online (Sandbox Code Playgroud) 我有两个服务器:一个用于开发,可以轻松访问WEB,另一个用于生产,只能使用代理访问WEB.
我想从我的生产服务器调用SOAP WEB服务.
以下是代码(URL是假的):
$url = 'https://www.webservice.com/soap.php';
$wsdl = 'https://www.webservice.com/soap.php?wsdl';
$client = new SoapClient
(
$wsdl,
array
(
'location' => $url,
'proxy_host' => 'www.myproxy.com',
'proxy_port' => 8080,
)
);
$namespace = 'urn:mynamespace';
$header = array
(
'header1' => 'H1',
'header2' => 'H2',
'header3' => 'H3',
);
$client->__setSoapHeaders(new SoapHeader($namespace, 'myHeader', $header));
$params = array
(
'param1' => 'val1',
'param2' => 'val2',
'param3' => 'val3',
);
$result = $client->method($params);
Run Code Online (Sandbox Code Playgroud)
我从我的开发服务器运行它,我得到了预期的结果.现在我从我的生产服务器运行它,我得到:
PHP Warning: SoapClient::SoapClient(https://www.webservice.com/soap.php?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 400 …Run Code Online (Sandbox Code Playgroud) 嗨,我有这个课要测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/service.xml"})
public class Test {
@Autowired private CommonService commonService;
Run Code Online (Sandbox Code Playgroud)
调试时,我在CommonService上获得一个对象,该对象的属性为SdkDynamicAopProxy。
如何在我的属性commonService上获得一个CommonServiceImp对象?
commonService
public interface CommonService {...}
Run Code Online (Sandbox Code Playgroud)
CommonServiceImp
@Service("commonService")
@Transactional("transactionManager")
public class CommonServiceImp implements CommonService {
@Autowired private CommonDaoJdbcImp commonDao; ...}
Run Code Online (Sandbox Code Playgroud)
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<import resource="/bbb-dao.xml"/>
<context:component-scan base-package="aaa.bbb.service"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" /> -->
<tx:annotation-driven />
<task:annotation-driven />
Run Code Online (Sandbox Code Playgroud)
我的tomcat在8080上运行
apache在80上运行
我实现了
<Location />
ProxyPass ajp://localhost:8080/ retry=0 timeout=30
ProxyPassReverse ajp://localhost:8080/
</Location>
Run Code Online (Sandbox Code Playgroud)
我无法通过apache访问我的java应用程序,并且不断出错
[Thu May 23 15:47:33 2013] [error] (120006)APR does not understand this error code: proxy: read response failed from (null) (localhost)
[Thu May 23 15:48:15 2013] [error] (70014)End of file found: ajp_ilink_receive() can't receive header
[Thu May 23 15:48:15 2013] [error] ajp_read_header: ajp_ilink_receive failed
[Thu May 23 15:48:15 2013] [error] (120006)APR does not understand this error code: proxy: read response failed from (null) (localhost)
Run Code Online (Sandbox Code Playgroud)
任何建议解决ajp代理错误
我requests在我的脚本中使用模块,我想了解方法中的proxies参数get().这个答案已经发布了以下代码来说明proxies参数的用法:
http_proxy = "10.10.1.10:3128"
https_proxy = "10.10.1.11:1080"
ftp_proxy = "10.10.1.10:3128"
proxyDict = {"http":http_proxy, "https":https_proxy, "ftp":ftp_proxy }
r = requests.get(url, headers=headers, proxies=proxyDict)
Run Code Online (Sandbox Code Playgroud)
这是我的问题:
为什么我们传递多个代理get()?怎么get()用它们?它一个接一个地尝试吗?
有代理人说,a.b.c.d:port我怎么知道它的协议类型?当您从hidemyass.com购买高级代理时,它ip:port仅以格式发送代理,并且不发送协议类型.那么我应该传递给requests.get()方法呢?
我有这些疑虑,因为我对代理一般都不太了解,以及它们是如何工作的.如果有人解释这一点,那将会很棒.
我试图在NetBeans 7.4中设置maven代理,因为我在代理后面.我从工具>选项>常规>代理设置中在NetBeans中设置代理,它工作正常.但是当我尝试构建项目时,我仍然遇到错误.
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
我搜索了错误消息,然后在maven的settings.xml文件中设置了相同的代理,但是再次出现错误.
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required. -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
有谁知道什么是错的?
添加代理设置:
<proxies>
<!-- proxy
| Specification …Run Code Online (Sandbox Code Playgroud)