【问题标题】:Artillery.io how send headersArtillery.io 如何发送标头
【发布时间】:2020-08-18 10:09:13
【问题描述】:

在测试 socket.io 之前,我需要将标头发送到服务器。我该怎么做?

我尝试了,但是我想要的header没有发送到服务器

Scenario

谢谢。

【问题讨论】:

    标签: node.js websocket socket.io


    【解决方案1】:

    您可以像这样在配置中的默认参数中设置标题:

    config:
        target: "http://localhost:3000"
        phases:
            - duration: 10
              arrivalRate: 100
        defaults:
            headers:
                authorization: token
                ...
    scenarios:
    ...
    

    【讨论】:

    • 谢谢。如何在标头中发送用户代理?
    【解决方案2】:

    文档:https://artillery.io/docs/guides/guides/test-script-reference.html

    config:
      target: https://my.microservice.internal
      phases:
        - duration: 600
          arrivalRate: 10
      defaults:
        headers:
          x-api-key: "xyz"
    scenarios:
      - flow:
          - get:
              url: "/"
    

    【讨论】:

      【解决方案3】:

      您也可以发送个别请求,例如:

            - post:
                url: '/graphql'
                headers:
                  Authorization: 'Bearer {{ token }}'
                json:
                  query: |
                    {
                      currentUser {
                        id
                        token
                      }
                    }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-17
        • 1970-01-01
        • 2018-02-08
        • 2019-07-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多