POST data with HEAD Request

梦想的初衷 提交于 2019-12-01 05:05:38

问题


Is it possible to send POST data with a HEAD Request?


回答1:


No, a HEAD request is different from a POST request. A HEAD request does not accept post data. From the HTTP specification section 9.4:

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

Since a GET request does not contain post data, a HEAD request also does not.




回答2:


Using Arduino is frequently used this way to send data:

  ArduinoClient.print("HEAD /wsendtemp.php?c1=");
  ArduinoClient.print(temp[0]);
  ArduinoClient.print("&time=");
  ArduinoClient.print(micros());

  ArduinoClient.println(" HTTP/1.1"); // attenzione allo spazio
  //ArduinoClient.println("Host: 127.0.0.1");
  ArduinoClient.println("Host: www.mcmajan.com");//184,173,194,61
  ArduinoClient.println("User-Agent:Arduino");
  ArduinoClient.println("Accept: text/html");
  ArduinoClient.println("Connection: close");
  ArduinoClient.println();
  ArduinoClient.stop();


来源:https://stackoverflow.com/questions/4529066/post-data-with-head-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!