模拟,测试和跟踪HTTP请求和响应:mockbin
cm54
10年前
Mockbin能够让你生成 custom endpoints 来模拟,测试和跟踪HTTP请求和响应。
OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\"foo\": \"bar\"}"); Request request = new Request.Builder() .url("http://mockbin.com/request?foo=bar&foo=baz") .post(body) .addHeader("cookie", "foo=bar; bar=baz") .addHeader("accept", "application/json") .addHeader("content-type", "application/json") .addHeader("x-pretty-print", "2") .build(); Response response = client.newCall(request).execute();
特性
- 使用HAR 格式
- 支持JSON, YAML, XML, HTML output
- plays nice with proxies (uses the X-Forwarded-* headers for IP resolution)
- allows for HTTP Method Override using the headerX-HTTP-Method-Overrideor through query string parameter:_method
- create custom bins for experimenting log collection