How to wait inside a function for some signal ?

I am wondering whats the right way to do that .
I have a function that has to send some wifi data , i am calling this function once .
This function send some data to a wifi module via serial , wait for a ">" respond , and then send him the data .

I wonder how should i wait to the ">" respond inside that function , so here it is :

String thisdata="HTTP/1.1 200 OK\r\n Content-Type:application/json\r\n";
     
    String toSend="AT+CIPSEND=0,";
    int dlen=thisdata.length();
    toSend+=dlen;
    toSend+="\r\n";
    wifiSerial.println(toSend);

   // here i sent this : AT+CIPSEND=0,50
  // now i have to wait for the incoming wifi , to the sign ">"

    
    String wifiContent="";
    int readWifiIndex=0;
     
    boolean hasdata=0;
    while( wifiSerial.available()   ) 
       {   
             
             wifiContent[readWifiIndex]=wifiSerial.read();
             readWifiIndex++;
             delay(10);      
             hasdata=1;            
        }

// did i had the ">" sign ??? if yes do something, if no , check wifi serial again.

Have you considered:
A) using "break"
B) not using "delay"
C) bounds checking your array accesses
D) not using the String class?

The 2nd example in Serial Input Basics uses a line-feed as an end-marker. It could easily be changed to >. The 3rd example uses < and > as start and end markers.

These examples don't block the Arduino while waiting for the complete message.

I suspect either of them could be adapted to your situation.

...R

// now i have to wait for the incoming wifi , to the sign ">"
bool gotTheSign = false;
char theSign = '>';
while(!gotTheSign)
{
   if(wifiSerial.available())
   {
       char a = wifiSerial.read();
       if(a == theSign)
          gotTheSign = true;
   }
}

You can easily expand this to wait until the > arrives, but not more than two weeks (or whatever interval seems reasonable, as long as reasonable is not more than 7 weeks).

ok thanks a lot .