我正在开发一个简单的HTTPS代理(用Python编写),它接收POST/GET请求/响应,应用一些转换,最后将结果转发给收件人.我需要以"流"方式处理分块编码的请求/响应,这意味着只要接收到一个块,代理就会转换它并将其转发给接收者.
在决定支持分块编码请求之前,我一直在使用mitmproxy http://mitmproxy.org/并且它工作得很好.不幸的是,我注意到在让我处理响应/请求之前它一直等到收到整个主体.
如何实现支持分块编码请求/响应的代理?你有没有人做过这样的事情?
谢谢
编辑:更多信息我的使用案例
我需要处理POST请求和GET响应.
在POST请求中,我收到一个JSON对象,我必须加密它的一些值.
在GET响应中,我收到一个JSON对象,我必须解密它的一些值.
到目前为止,以下代码完美地运行:
def handle_request(self, r):
if(r.method=='POST'):
// encryption of r.get_form_urlencoded()
def handle_response(self, r):
if(r.request.method=='GET'):
// decryption of r.content
Run Code Online (Sandbox Code Playgroud)
如何用单个块做同样的事情?
编辑:更新
在评估了不同的解决方案之后,我决定选择Squid(代理)+ ICAP(内容改编).
我已经成功配置了Squid,性能非常好.不幸的是,我找不到合适的ICAP服务器(如果可能的话,用Python)来进行内容改编(修改).我认为这一个https://github.com/netom/pyicap可以完成这项工作,但看起来它没有读取myPOST请求的正文.
你们知道我可以和Squid一起使用的Python ICAP服务器吗?
谢谢
我正在使用openshift来部署我构建的一些小应用程序.一切都很好,但有时,不要问我为什么,当我尝试登录(发布请求)时,我收到此错误(等待5分钟后或多或少:
代理错误
代理服务器从上游服务器收到无效响应.代理服务器无法处理请求POST /登录.
原因:从远程服务器读取时出错
不同的请求工作,只有这个登录请求似乎被打破.我的应用程序的日志不显示错误,似乎没有处理请求.有什么建议?
我有这个错误我无法连接到代理我花了4-5个小时摆弄网络寻找线索但我无法解决这个问题..
我正在使用Windows azure,我只有代理问题.
我的命令如下:
1.与代理连接
git config --global http.proxy http://<username>:<password>@mapevent.azurewebsites.net:443
Run Code Online (Sandbox Code Playgroud)
2.Clone错误
git clone https://<username>@mapevent.scm.azurewebsites.net:443/mapevent.git
Cloning into 'mapevent' ...
fatal: unable to access 'https://<username>@mapevent.scm.azurewebsites.net:443/mapevent.git/': Recv failure: Connection was reset
Run Code Online (Sandbox Code Playgroud)
我也试过端口8080,但说"无法解决"并使用推送,但似乎都失败了.
我是Git的新手而且我没有进展:(
请帮助我,我有一个项目要在接下来的几周内完成.
我有一个Jenkins CI,配置如下:
我很肯定我的代理配置正确.但是当我尝试下载插件或更新Jenkins上的插件时.我收到这个错误
Git Client Plugin
Failure -
hudson.util.IOException2: Failed to download from http://updates.jenkins-ci.org/download/plugins/git-client/1.8.1/git-client.hpi
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:794)
.
.
Caused by: java.net.ProtocolException: Server redirected too many times (20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
.
.
.
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:764)
... 7 more
Caused by: java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1636)
Run Code Online (Sandbox Code Playgroud)
但是我可以对实际的URL/URI进行Curl或wget来下载插件
感谢您的帮助和反馈
我知道袜子代理是一个代理,它仅将流量中继到dst ip:port和一个支持CONNECT请求的HTTP代理,它也仅将流量中继到http请求标头中的dest主机。 (例如效率)?
我尝试进行切入点,以记录SQL查询
@Before("execution(* org.springframework.jdbc.core.JdbcTemplate.*(String, ..))")
public void logSQLQueries() {
System.out.println("@@");
}
Run Code Online (Sandbox Code Playgroud)
但我明白了
java.lang.IllegalArgumentException: Can not set org.springframework.jdbc.core.JdbcTemplate field com.xyz.abc.dao.ABCDaoImpl.jdbcTemplate to com.sun.proxy.$Proxy53
Run Code Online (Sandbox Code Playgroud)
我在我的*-servlet.xml中创建了jdbcTemplate bean,并在我所有的DAO中自动启用了它.工作得非常好,但添加切入点会产生异常.有任何想法吗 ??
我的设置:
apt-get install也可以以下是我到目前为止配置代理所做的工作:
/etc/profile.d/proxy.sh:
export http_proxy="http://<my_proxy>:<my_port>"
export https_proxy="http://<my_proxy>:<my_port>"
export ftp_proxy="http://<my_proxy>:<my_port>"
Run Code Online (Sandbox Code Playgroud)
为了获得工作能力,修改了/etc/apt/apt.conf.d/01proxy:
Acquire::http::Proxy “http://<my_proxy>:<my_port>"
Run Code Online (Sandbox Code Playgroud)
要在使用sudo时保持env变量,修改/etc/sudoers.d/proxy:
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
Run Code Online (Sandbox Code Playgroud)
我还在设置 - >网络 - >网络代理中设置了HTTP/HTTPS/FTP代理设置,然后单击"应用系统范围".
问题是,当我尝试pip install(有或没有sudo)时,它失败并出现错误:
$ pip -vv install git-review
Downloading/unpacking git-review
Getting page http://pypi.python.org/simple/git-review
Could not fetch URL http://pypi.python.org/simple/git-review: <urlopen error [Errno -2] Name or service not known>
Will skip URL http://pypi.python.org/simple/git-review when looking for download links for git-review
Getting page …Run Code Online (Sandbox Code Playgroud) 是否有相当于Dart/pub 的grunt-connect-proxy?
在生产中,前端内容被构建(pub build)作为静态资源,并且可以由任何Web服务器(dart-agnostic)提供服务.
在开发过程中,我想与后端服务器(非Dart)进行通信,而不需要构建整个前端pub build并与后端服务器一起使用,只是为了查看前端代码中的一些单一更改.
此功能已经提出,但截至目前已进行了分类:https://code.google.com/p/dart/issues/detail? id = 16851 .
这似乎只能通过pub来完成,因为即使在同一主机中与后端进行通信也是通过CORS完成的 - 至少这是文档中鼓励的内容.
我正在尝试在python中创建一个http代理.到目前为止,除了https工作之外,我已经得到了所有东西,因此下一步是实现CONNECT方法.
我对进行https隧道传输时需要发生的事件链稍微感到困惑.从我的理解,我应该有这个连接到谷歌:
Broswer - >代理
CONNECT www.google.co.uk:443 HTTP/1.1\r\n\r\n
Run Code Online (Sandbox Code Playgroud)
然后代理应建立与google.co.uk的安全连接,并通过发送确认:
代理 - >浏览器
HTTP/1.1 200 Connection established\r\n\r\n
Run Code Online (Sandbox Code Playgroud)
在这一点上,我希望浏览器现在可以继续执行它首先要做的事情,但是,我要么什么也得不到,或者得到一串我无法解码的字节().我一直在阅读任何与ssl隧道有关的事情,我想我应该将所有字节从浏览器转发到服务器,以及相反的方式.但是,当这样做时,我得到一个:
HTTP/1.0 400 Bad Request\r\n...\r\n
Run Code Online (Sandbox Code Playgroud)
一旦我发送了200个代码,接下来我应该做什么?
我的connect方法的代码片段:
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if headers["Method"] == "CONNECT":
client = ssl.wrap_socket(client)
try:
client.connect(( headers["Host"], headers["Port"] ))
reply = "HTTP/1.0 200 Connection established\r\n"
reply += "Proxy-agent: Pyx\r\n"
reply += "\r\n"
browser.sendall( reply.encode() )
except socket.error as err:
print(err)
break
while True:
now not sure
Run Code Online (Sandbox Code Playgroud)
非常感谢帮助!
我试图从proxymesh.com使用代理
我目前正在使用以下代码,它会打开Chrome并创建一个javascript警报来输入用户名和密码.我每次运行脚本的新实例时都会手动执行此操作.
如果有人可以帮助自动化它.
有两种方法可以做到,
以某种方式通过Chrome选项传递用户名和密码
要么
以某种方式使webdriver切换到javascript警报并在那里输入用户名和密码.
这是我的代码到目前为止,
from selenium import webdriver
chrome_option = webdriver.ChromeOptions()
chrome_option.add_argument("--proxy-server=http://us.proxymesh.com:31280")
b = webdriver.Chrome('chromedriver.exe',
chrome_options=chrome_option)
"Do Something"
Run Code Online (Sandbox Code Playgroud)
提前致谢
proxy ×10
http ×3
apache ×2
python ×2
angular-dart ×1
aspectj ×1
connect ×1
connection ×1
dart ×1
dart-pub ×1
git ×1
https ×1
networking ×1
node.js ×1
openshift ×1
pip ×1
python-2.7 ×1
selenium ×1
socks ×1
spring ×1
spring-aop ×1
spring-mvc ×1
squid ×1
tunnel ×1
ubuntu ×1
vpn ×1