moco框架

本文详细介绍了如何使用Moco Runner进行HTTP请求模拟,并解决了浏览器与JMeter中的乱码问题。同时,提供了HTTP请求及重定向的示例,以及如何在不同场景下配置响应内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载链接:http://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/0.11.0/----moco-runner-0.11.0-standalone.jar
启动命令:java -jar ./moco-runner-0.11.0-standalone.jar http -p 8888 -c startup1.json
请求链接:http://192.168.0.103:8888/demo
解决浏览器打开乱码问题--response中加:
"headers":{
                   "Content-Type":"text/html;charset=jbk"
                 }
解决jmeter中乱码,在BeanShell PostProcessor中加:
"Content-Type":"text/html;charset=jbk"
格式:
[
  {
    "description":"这是包括全部的get请求",
    "request":{
      "uri":"/getAllDemo",
      "method":"get",
      "cookies":{
        "login":"true"
      },
      "headers":{
        "content-type":"application/json"
      },
      "queries":{
        "name":"zuohuajian",
        "age":"25"
      }
    },
    "response":{
      "json":{
        "zuohuajian":"success",
        "enabled":"1"
      },
      "headers":{
        "Content-Type":"text/html;charset=jbk"
      }
    }
  },{
  "description":"这是包括全部的post请求",
  "request":{
    "uri":"/postAllDemo",
    "method":"post",
    "cookies":{
      "login":"true"
    },
    "headers":{
      "content-type":"application/json"
    },
    "json":{
      "name":"jinzhu",
      "age":"24"
    }
  },
  "response":{
    "json":{
      "jinzhu":"success",
      "enabled":"2"
    },
    "headers":{
      "Content-Type":"text/html;charset=jbk"
    }
  }
}
]

重定向:
[
  {
    "description":"重定向到百度",
    "request":{
      "uri":"/redirect"
    },
    "redirectTo":"http://www.baidu.com"
  },
  {
    "description":"这是重定向到的请求",
    "request":{
      "uri":"/redirect/topath"
    },
    "redirectTo":"/redirect/new"
  },
  {
    "description":"这是被重定向到的请求",
    "request":{
      "uri":"/redirect/new"
    },
    "response":{
      "text":"重定向成功啦",
      "headers":{
        "Content-Type":"text/html;charset=jbk"
      }
    }
  }
]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值