我需要一个实时测试服务器,它通过HTTP GET接受我对基本信息的请求,并允许我POST(即使它真的什么都不做)。这完全是为了测试目的。

这里有一个很好的例子。它很容易接受GET请求,但我需要一个接受POST请求以及。

有人知道我也可以发送虚拟测试消息的服务器吗?


当前回答

一些在线httpbin:

https://httpbin.org/ https://httpbingo.org/ https://quic.aiortc.org/httpbin/

获取客户端ip,端口,ua..

http://ifconfig.io/

获取客户端ip, isp

https://www.cip.cc/

其他回答

如果你需要或想要一个简单的HTTP服务器与以下:

是否可以在本地运行或在与公共Internet密封的网络中运行 有基本的认证吗 处理POST请求

我在PyPI上已有的出色的SimpleHTTPAuthServer之上构建了一个。这增加了POST请求的处理: https://github.com/arielampol/SimpleHTTPAuthServerWithPOST

否则,所有其他公开可用的选项都已经很好很健壮了。

https://httpbin.org/

它将在请求中使用以下类型的任何数据进行回显:

https://httpbin.org/anything Returns most of the below. https://httpbin.org/ip Returns Origin IP. https://httpbin.org/user-agent Returns user-agent. https://httpbin.org/headers Returns header dict. https://httpbin.org/get Returns GET data. https://httpbin.org/post Returns POST data. https://httpbin.org/put Returns PUT data. https://httpbin.org/delete Returns DELETE data https://httpbin.org/gzip Returns gzip-encoded data. https://httpbin.org/status/:code Returns given HTTP Status code. https://httpbin.org/response-headers?key=val Returns given response headers. https://httpbin.org/redirect/:n 302 Redirects n times. https://httpbin.org/relative-redirect/:n 302 Relative redirects n times. https://httpbin.org/cookies Returns cookie data. https://httpbin.org/cookies/set/:name/:value Sets a simple cookie. https://httpbin.org/basic-auth/:user/:passwd Challenges HTTPBasic Auth. https://httpbin.org/hidden-basic-auth/:user/:passwd 404'd BasicAuth. https://httpbin.org/digest-auth/:qop/:user/:passwd Challenges HTTP Digest Auth. https://httpbin.org/stream/:n Streams n–100 lines. https://httpbin.org/delay/:n Delays responding for n–10 seconds.

如果你想要一个本地测试服务器接受任何URL并将请求转储到控制台,你可以使用node:

const http = require("http");

const hostname = "0.0.0.0";
const port = 3000;

const server = http.createServer((req, res) => {
  console.log(`\n${req.method} ${req.url}`);
  console.log(req.headers);

  req.on("data", function(chunk) {
    console.log("BODY: " + chunk);
  });

  res.statusCode = 200;
  res.setHeader("Content-Type", "text/plain");
  res.end("Hello World\n");
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://localhost:${port}/`);
});

将其保存在文件'echo.js'中,并按如下方式运行:

$ node echo.js
Server running at http://localhost:3000/

然后你可以提交数据:

$ curl -d "[1,2,3]" -XPOST http://localhost:3000/foo/bar

这将显示在服务器的标准输出:

POST /foo/bar
{ host: 'localhost:3000',
  'user-agent': 'curl/7.54.1',
  accept: '*/*',
  'content-length': '7',
  'content-type': 'application/x-www-form-urlencoded' }
BODY: [1,2,3]

一些在线httpbin:

https://httpbin.org/ https://httpbingo.org/ https://quic.aiortc.org/httpbin/

获取客户端ip,端口,ua..

http://ifconfig.io/

获取客户端ip, isp

https://www.cip.cc/

你可能不需要任何网站,只需要打开浏览器,按F12来访问开发人员工具>控制台,然后在控制台写一些JavaScript代码来做到这一点。

下面我将分享一些实现这一目标的方法:

对于GET请求: *。使用jQuery:

$.get("http://someurl/status/?messageid=597574445", function(data, status){
      console.log(data, status);
});

POST请求:

使用jQuery $.ajax:

var url= "http://someurl/",
          api_key = "6136-bc16-49fb-bacb-802358",
          token1 = "Just for test",
          result;
    $.ajax({
            url: url,
            type: "POST",
            data: {
              api_key: api_key,
              token1: token1
            },
          }).done(function(result) {
                  console.log("done successfuly", result);
          }).fail(function(error) {
              console.log(error.responseText, error);
          });

使用jQuery,添加和提交

var merchantId = "AA86E",
    token = "4107120133142729",
    url = "https://payment.com/Index";

var form = `<form id="send-by-post" method="post" action="${url}">
            <input id="token" type="hidden" name="token" value="${merchantId}"/>
            <input id="merchantId" name="merchantId" type="hidden" value="${token}"/>
            <button type="submit" >Pay</button>
            </div>
            </form> `; 
    $('body').append(form);
    $("#send-by-post").submit();//Or $(form).appendTo("body").submit();

使用纯JavaScript:

`var api_key = "73736-bc16-49fb-bacb-643e58",
    recipient = "095552565",
    token1 = "4458",
    url = 'http://smspanel.com/send/';`

``var form = `<form id="send-by-post" method="post" action="${url}">
              <input id="api_key" type="hidden" name="api_key" value="${api_key}"/>
              <input id="recipient" type="hidden" name="recipient"  value="${recipient}"/>
              <input id="token1" name="token1" type="hidden" value="${token1}"/>
              <button type="submit" >Send</button>
        </div>
    </form>`;``

document.querySelector("body").insertAdjacentHTML('beforeend',form);
document.querySelector("#send-by-post").submit();

甚至使用ASP。Net:

var url = "https://Payment.com/index";
Response.Clear();
var sb = new System.Text.StringBuilder();

sb.Append("<html>");
sb.AppendFormat("<body onload='document.forms[0].submit()'>");
sb.AppendFormat("<form action='{0}' method='post'>", url);
sb.AppendFormat("<input type='hidden' name='merchantId' value='{0}'>", "C668");
sb.AppendFormat("<input type='hidden' name='Token' value='{0}'>", "22720281459");
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");
Response.Write(sb.ToString());
Response.End();