0
嘿,我正在做的和Arduino的項目,我想從一個HTTP請求得到了身體,這裏是代碼:我如何從HTTP響應中獲取正文?
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(100);
int liniea_info = 0;
while(client.available()){
String line = client.readStringUntil('\r');
if(liniea_info == 13){Serial.print(line);}
Serial.print(liniea_info);
++liniea_info;
}
這工作不錯,不整liniea_info
返回我:
Requesting URL: /output/***.csv?colors=11
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: X-Requested-With
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Sat, 17 Jun 2017 08:09:31 GMT
Connection: close
Set-Cookie: SERVERID=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/
Cache-control: private
34
colors,day,timestamp
11,12,2017-06-17T07:48:10.619Z
0
我以爲用int liniea_info
我只會得到我想要的那一行,即線條"11,12,2017-06-17T07:48:10.619Z"
,但是不行,只打印第一行。
任何人都看到我在做什麼錯誤或如何做到這一點?
這不是C,請取下標籤或正確的.... –
HTTPS替換它:// EN。 wikipedia.org/wiki/Chunked_transfer_encoding –