使用 WiFlyHQ 库我尝试发送 POST 请求,似乎请求标头被裁剪,如果我检查服务器上的请求,我可以看到以下内容:
headers: { host: 'localhost:3000', 'content-type': 'application' },
使用此设置;
void SendJasonPacket()
{
wifly.open(Server, ServerPort);
wifly.println("POST / HTTP/1.1");
wifly.println("Host: localhost:3000");
wifly.println("Content-type: application/json");
wifly.println("Accept: application/json");
wifly.println("Content-Length: 93");
wifly.println("User-Agent: easyNAM/0.0.1");
wifly.println("{'checkin':{'device_token': '122','card_token': '12312', 'timestamp': '2012-10-29T14:31:03'}}");
wifly.close();
}
我尝试了几个不同的标题,这就是我得到的:
headers: { 'user-agent': 'easyNAM/0.0.1', accept: 'application/j' },
headers: { accept: 'application/json', 'user-agent': 'easyNAM/0' },
headers: { host: 'localhost:3000', 'content-type': 'application' },
看来,它在特定字符计数后被裁剪,不确定我在这里做错了什么......