HTTPClient Get Timeout?

Is there any timeout at "client.available()"? In my opninion not. It's stuck in the while loop if you move out of the wifi range. Is there a way to get a timeout?

Example:

HttpClient client;
client.get("http://arduino.cc/asciilogo.txt");

while (client.available()) {
char c = client.read();
Serial.print(c);
}
Serial.flush();

Thanks for your help.

from "HttpClient.cpp"

unsigned int HttpClient::get(String &url) {
begin("curl");  
addParameter(url);  
return run();
}

Rewrite HttpClient by use directly Process.

curl -h
...
--connect-timeout SECONDS  Maximum time allowed for connection
...
-m, --max-time SECONDS  Maximum time allowed for the transfer
/*
  Running process using Process class.

 This sketch demonstrate how to run linux processes
 using an Arduino Yún.

 created 5 Jun 2013
 by Cristian Maglie

 This example code is in the public domain.

 http://arduino.cc/en/Tutorial/Process

 */

#include <Process.h>

void setup() {
  Bridge.begin();
   // Initialize Serial
  Serial.begin(9600);

  // Wait until a Serial Monitor is connected.
  while (!Serial);
}

void loop() {
  // Do nothing here.
  Process p;              
  p.begin("curl");      
  p.addParameter("--connect-timeout");
  p.addParameter("10");
  p.addParameter("-m");
  p.addParameter("60"); 
  p.addParameter("http://arduino.cc/asciilogo.txt"); 
  p.run();
   // Print command output on the Serial.
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
  delay(5000);
}

Is there a way to check if the timeout did occur ? Or is the only way to add a Millis() counter?

 curl -s -I --connect-timeout 5 --max-time 10 http://www.arduino.cc | grep -q '200 OK';

use -I only check header.

I don't think that's what i meant. I mean, if a timeout occurs, how can i get a notification
that it had been that way ? I need to post certain interrup counts with curl but when they
are not posted alright the interrupt count doesn't need to be reset to 0, he'll just retry next
time and adds the count then.

if you know what i mean :slight_smile:

I think curl will exit with an exitValue greater than 0 if an error occurs. Check exitValue() from both Process and HTTPClient