admin管理员组文章数量:1379611
I'm observing a series of redirects in chrome dev tools, "Networking" tab:
I need to be able to pause redirect chain after a request has appeared in the "Networking" (so that I can copy it as cURL) but before it is executed. Something like "Pause on any network activity". I have searched for this feature in Chrome dev tools, Firefox Web Developer, Firebug, Safari - but to no avail. The closest thing is "Pause on XHR" in firebug, but these redirects are not XHRs.
I will accept a non-browser solution (a script?) if it does the job, although I feel that this should be possible with browser dev tools.
I'm observing a series of redirects in chrome dev tools, "Networking" tab:
I need to be able to pause redirect chain after a request has appeared in the "Networking" (so that I can copy it as cURL) but before it is executed. Something like "Pause on any network activity". I have searched for this feature in Chrome dev tools, Firefox Web Developer, Firebug, Safari - but to no avail. The closest thing is "Pause on XHR" in firebug, but these redirects are not XHRs.
I will accept a non-browser solution (a script?) if it does the job, although I feel that this should be possible with browser dev tools.
Share Improve this question asked Oct 30, 2015 at 17:11 Denys Kniazhev-Support UkraineDenys Kniazhev-Support Ukraine 9,1228 gold badges48 silver badges64 bronze badges2 Answers
Reset to default 1I wasn't able to find a browser solution. As you're ok with non-browser solution, there is a python script (it also uses requests
library) that follows redirects, until some suffix is found and prints request for the cURL.
#!/usr/bin/env python
import requests
import sys
def formatRequestAscURL(request):
mand = "curl -X {method} -H {headers} -d '{data}' '{url}'"
method = request.method
url = request.url
data = request.body
headers = ["{0}: {1}".format(k, v) for k, v in request.headers.items()]
headers = " -H ".join(headers)
return mand.format(method=method, headers=headers, data=data, url=url)
def followUntilSuffix(startURL, suffix):
response = requests.get(startURL, allow_redirects=False)
session = requests.Session()
requests_iter = session.resolve_redirects(response, response.request)
for r in requests_iter:
if r.request.path_url.endswith(suffix):
print formatRequestAscURL(r.request)
return
print 'Required redirect isn\'t found'
if len(sys.argv) < 3:
print 'This script requires two parameters:\n 1) start url \n 2) url suffix for stop criteria'
sys.exit()
startURL = sys.argv[1]
stopSuffix = sys.argv[2]
followUntilSuffix(startURL, stopSuffix)
Adding this because this was the first search result for me.
In firefox you can add a XHR request as explained here: https://firefox-source-docs.mozilla/devtools-user/debugger/set_an_xhr_breakpoint/index.html
本文标签: javascriptStop on a network request in browser dev toolsStack Overflow
版权声明:本文标题:javascript - Stop on a network request in browser dev tools - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744505402a2609564.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论