http请求头设置

Curl

curl -i -H 'Content-Type: application/json' -i/--include     输出时包括protocol头信息
curl -x 10.12.15.16:8080 www.facebook.com -x/--proxy <proxyhost[:port]> 指定代理服务器地址和端口,端口默认为1080

Jquery

contentType: "application/x-www-form-urlencoded"

Content-Type: application/x-www-form-urlencoded与Content-Type: application/json比较:

//contentType: "application/x-www-form-urlencoded;charset=utf-8",
//data: {parameter_A:1,parameter_B:'liuchao'}

//print_r($_POST); 
//contentType: "application/json; charset=utf-8", 
//data: JSON.stringify({parameter_A:1,parameter_B:'liuchao'}),
//data: '{parameter_A:1,parameter_B:"liuchao"}',

//print_r($_POST); 这种情况下接收不到POST参数,需要使用file_get_contents('php://input')
//print_r(file_get_contents('php://input'));

程序接口日志应该包括Request Headers,Request Body,Response Headers,Response Body信息。

猜你喜欢

转载自www.cnblogs.com/hnhycnlc888/p/9854220.html