1
我正在嘗試使用BrowserMob代理來捕獲有關請求的信息。 讓它適用於沒有授權標頭的HTTP請求和HTTPS請求。Browsermob HTTPS請求與身份驗證頭
if(product == 'Product'):
headers = {
'Authorization': 'Bearer %s' % accessToken()
}
http_proxy = "http://localhost:" + str(self.proxy.port)
https_proxy = "https://localhost:" + str(self.proxy.port)
ftp_proxy = "ftp://localhost:" + str(self.proxy.port)
proxyDict = {
"http" : http_proxy,
"ftp" : ftp_proxy,
"https" : https_proxy
}
fullurl = baseurl
fullurl += '/'
fullurl += baseuri
logger.console("fullurl: '%s'" % fullurl)
response = requests.request(method,fullurl,proxies=proxyDict,verify=False,data=payload,headers=headers)
如果我刪除'proxies = proxyDict',請求會經過。請求似乎超時,如果我去通過代理,雖然和我得到的波紋管例外:
Exception: Error creating SSLEngine for connection to client to impersonate upstream host: null
at net.lightbody.bmp.mitm.manager.ImpersonatingMitmManager.clientSslEngineFor(ImpersonatingMitmManager.java:227) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ProxyToServerConnection$3.execute(ProxyToServerConnection.java:739) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow.doProcessCurrentStep(ConnectionFlow.java:140) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow.processCurrentStep(ConnectionFlow.java:128) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow.advance(ConnectionFlow.java:90) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlowStep.onSuccess(ConnectionFlowStep.java:83) ~[browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow$2.operationComplete(ConnectionFlow.java:149) ~[browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:683) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:139) [browsermob-dist-2.1.0.jar:?]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [browsermob-dist-2.1.0.jar:?]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow.doProcessCurrentStep(ConnectionFlow.java:140) [browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow.access$000(ConnectionFlow.java:14) [browsermob-dist-2.1.0.jar:?]
at org.littleshoot.proxy.impl.ConnectionFlow$1.run(ConnectionFlow.java:124) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:73) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) [browsermob-dist-2.1.0.jar:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:374) [browsermob-dist-2.1.0.jar:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [browsermob-dist-2.1.0.jar:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212) ~[browsermob-dist-2.1.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3952) ~[browsermob-dist-2.1.0.jar:?]
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790) ~[browsermob-dist-2.1.0.jar:?]
at net.lightbody.bmp.mitm.manager.ImpersonatingMitmManager.getHostnameImpersonatingSslContext(ImpersonatingMitmManager.java:242) ~[browsermob-dist-2.1.0.jar:?]
at net.lightbody.bmp.mitm.manager.ImpersonatingMitmManager.clientSslEngineFor(ImpersonatingMitmManager.java:223) ~[browsermob-dist-2.1.0.jar:?]
... 20 more
是否browsermob處理這樣的授權或我做錯了我?有沒有另一種代理解決方案可以更好地爲此工作?我期待使用har結果。