代码之家  ›  专栏  ›  技术社区  ›  Aditya

RESTAPI/SOAPUI工具-如何在到达终点时手动传递Cookie

  •  0
  • Aditya  · 技术社区  · 7 年前

    我是RESTful服务测试的新手,在哪里建立到需要通过Cookie的端点的连接时遇到了麻烦。我有参数和值,但不知道如何在点击请求时手动传递Cookie(而不是通过header或Groovy脚本)。

    2 回复  |  直到 7 年前
        1
  •  1
  •   so-random-dude    7 年前

    太长,读不下去了

    Cookie只不过是一个有名字的头 cookie 以及格式中的标题值 name=value; anothername=anothervalue; yetanotherone=yetanothervalue; ,就http请求而言

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie

    由服务器使用设置的Cookie头发送。

    浏览器的隐私设置阻止cookies。

    如何发送Cookie

    就像其他头球一样。唯一的条件是,标头名称应为 曲奇 标题值应为 格式。

    curl -v --cookie "USER_TOKEN=my-most-secure-session-id" http://localhost:8080/
    

    如果您想让curl读取cookie文件并发送它

    使用 curl -c /path/to/cookiefile http://yourhost/

    https://curl.haxx.se/docs/http-cookies.html

    Sending cookie as request header in SOAP UI request for rest web service

    使用chrome或firefox建立用户会话(登录),转到developer选项卡,复制cookie值并将其与soapUI请求一起作为标头发送。(恭喜,你正在劫持你自己的会话)

    http://www.soapui.org/soapui-projects/form-based-authentication.html

    enter image description here

        2
  •  1
  •   iPirat    7 年前

    Cookie: name=value
    

    到服务器

    推荐文章