打印给定 url 的 HTTP 协议版本

发布于 2025-01-13 07:48:48 字数 749 浏览 3 评论 0原文

我正在使用 Vue CLI 构建一个 web 应用程序来分析 http 响应。我使用 axios 发出 get 请求,并使用 chrome 扩展允许发送跨域请求。

我的目标是打印 HTTP 协议版本,因为我在 axios 响应中找不到它,但我可以使用 chrome 开发工具看到它。

下面是我处理 axios 请求的方式:

axios({
    method: this.userMethod,
    url: url,
  })
    .then((r) => {
      this.response = r;
      };
    })
    .catch((e) => {
      console.error(e);
    });

其中“url”是 URL 对象。

是我激活后从网站(本例中为 StackOverflow)得到的响应CORS 扩展。

我想要得到的是 chrome 开发工具显示的“h2”协议版本。我的目标是获取它并将其打印在屏幕上,但我在 axios 响应中找不到它。 我已经使用命令行阅读了有关“curl”的内容,这也可以用 Javascript 实现吗?还是我完全偏离了方向?

响应标头的屏幕截图

I'm building a webapp using Vue CLI to analyze http responses. I'm using axios to make get requests and a chrome extension which allows to send cross-domain requests.

My goal is to print HTTP protocol version, as I can't find it in the axios response but I can see it using chrome dev tools.

Here how I handled the axios request:

axios({
    method: this.userMethod,
    url: url,
  })
    .then((r) => {
      this.response = r;
      };
    })
    .catch((e) => {
      console.error(e);
    });

Where 'url' is a URL object.

This is the kind of response I get from a site (StackOverflow in this example) once I activate the CORS extension.

What I want to get is the "h2" protocol version that chrome dev tools shows. My goal is to take that and print it on screen, but I can't find it in the axios response.
I've read about 'curl' using the command line, Is that possible with Javascript too or am I completely off path?

A screenshot of the response headers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文