Amazon get request ?
Posted: Tue Oct 06, 2015 12:50 pm
Using the weesp8266 for arudino , i manage to connect via tcp to my server in amazon .
Then trying to send get request ,which works in any browser(and http tool for requests) but NOT in the esp.
Here is the get
and here is the code:
Then trying to send get request ,which works in any browser(and http tool for requests) but NOT in the esp.
Here is the get
Code: Select all
GET /http://ec2-xx-xx-xx4-xx.compute-1.amazonaws.com/index.php HTTP/1.1
Host:ec2-52-91-234-18.compute-1.amazonaws.com
User-Agent:runscope/0.1
Content-Type:application/json
Accept-Encoding:gzip,deflate
and here is the code:
Code: Select all
char *hello = "GET /http://ec2-xx-x1-xxx-xx.compute-1.amazonaws.com/index.php HTTP/1.1\r\nHost:ec2-52-91-234-18.compute-1.amazonaws.com\r\nUser-Agent:runscope/0.1\r\nContent-Type:application/json\r\nAccept-Encoding:gzip,deflate\r\n";
Serial.println(hello);
wifi.send((const uint8_t*)hello, strlen(hello));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
if (len > 0) {
Serial.print("Received:[");
for(uint32_t i = 0; i < len; i++) {
Serial.print((char)buffer[i]);
}
Serial.print("]\r\n");