Edit and replay XHR chrome/firefox etc?

前端 未结 9 2075
有刺的猬
有刺的猬 2021-01-30 00:38

I\'ve been looking for a way to alter a XHR request made in my browser and then replay it again. Say I have a complete POST request done in my browser, and the only thing I want

相关标签:
9条回答
  • 2021-01-30 00:57

    Updating/completing zszep answer:

    After copying the request as cUrl (bash), simply import it in the Postman App:

    0 讨论(0)
  • 2021-01-30 00:58

    5 years have passed and this essential requirement didn't get ignored by the Chrome devs.
    While they offer no method to edit the data like in Firefox, they offer a full XHR replay.
    This allows to debug ajax calls.

    "Replay XHR" will repeat the entire transmission.

    0 讨论(0)
  • 2021-01-30 01:00

    Chrome now has Copy as fetch in version 67:

    Copy as fetch

    Right-click a network request then select Copy > Copy As Fetch to copy the fetch()-equivalent code for that request to your clipboard.

    https://developers.google.com/web/updates/2018/04/devtools#fetch

    Sample output:

    fetch("https://stackoverflow.com/posts/validate-body", {
      credentials: "include",
      headers: {},
      referrer: "https://stackoverflow.com/",
      referrerPolicy: "origin",
      body:
        "body=Chrome+now+has+_Copy+as+fetch_+in+version+67%3A%0A%0A%3E+Copy+as+fetch%0ARight-click+a+network+request+then+select+**Copy+%3E+Copy+As+Fetch**+to+copy+the+%60fetch()%60-equivalent+code+for+that+request+to+your+clipboard.%0A%0A&oldBody=&isQuestion=false",
      method: "POST",
      mode: "cors"
    });
    

    The difference is that Copy as cURL will also include all the request headers (such as Cookie and Accept) and is suitable for replaying the request outside of Chrome. The fetch() code is suitable for replaying inside of the same browser.

    0 讨论(0)
  • 2021-01-30 01:01

    My two suggestions:

    1. Chrome's Postman plugin + the Postman Interceptor Plugin. More Info: Postman Capturing Requests Docs

    2. If you're on Windows then Telerik's Fiddler is an option. It has a composer option to replay http requests, and it's free.

    0 讨论(0)
  • 2021-01-30 01:01

    No need to install 3rd party extensions!

    There exists the javascript-snippet, which you can add as browser-bookmark and then activate on any site to track & modify the requests. It looks like:

    For further instructions, review the github page.

    0 讨论(0)
  • 2021-01-30 01:06

    For Firefox the problem solved itself. It has the "Edit and Resend" feature implemented.

    For Chrome Tamper extension seems to do the trick.

    0 讨论(0)
提交回复
热议问题