1. Home
  2. Docs
  3. 使用手册
  4. 运维剧本
  5. 命令列表
  6. HttpCommand组件

HttpCommand组件

基于QML自带的XMLHttpRequest组件的简易封装,其具体源码在:https://github.com/aoyiduo/woterm/blob/main/private/playbooks/test/http.js
其参考例子:
https://github.com/aoyiduo/woterm/blob/main/private/playbooks/test/TestHttpCommand.qml

截取核心代码

import "http.js" as Http


asyncGenerator(function *(){
    yield Http.get(url.text).then(function(obj){
         Playbook.log("success to get------------")
         Playbook.log(obj.headers)
         Playbook.log("\r\n\r\n"+obj.body)
    ).catch(function(err){
         Playbook.log("failed to get content.", err.status, err.statusText)
    })
})()