Wificlient - multiple requests on same connection?

Just a question of effeciency -
This code works totally fine:

    for (int c = 0; c < dataPoints; c++) {
      if (data[c].indexOf(",") > 0) {
        if (fromPC) { Serial.println(data[c]); }
        channel = data[c].substring(0,data[c].indexOf(","));
        value = data[c].substring(data[c].indexOf(",")+1);
        String postData = channel + ":" + value;
    
        postData = pad(postData,12);
        postData.toCharArray(cv, 16);
        if (fromPC) { Serial.println(cv); }
        LcdString(cv);
        const int httpPort = 80;
        const char* host = "my.server.domain";
        String url = "/emoncms/input/post.json?node=1&json={" + channel + ":" + value + "}&apikey=abcd1234";
        WiFiClient client;
        yield();
        if (!client.connect(host, httpPort)) {
          if (fromPC) { Serial.println("Server connection failed"); }
          return;
        }
        client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
        yield();
        delay(500);
        while(client.available()) {
          value = client.readStringUntil('\r');
          if (fromPC) { Serial.println(value); }
        } //while
      } //if
    } //for

What I'm curious about is whether there's a way to do multiple GETs or POSTs from the same connection, rather than having to close and reopen the connection each time?

I tried leaving the connection creation and "connection: close" stuff outside of the loop, but it would only execute the first URL, not any of the subsequent ones. So I was just curious if there was a way to make this more efficient from a connection perspective?

Same exact question here. First response arrives fine, then no more.

I had a similar issue using GitHub - csquared/arduino-restclient: Arduino RESTful HTTP Request Library to send the rest requests (but of course you can that without the lib as well).

I changed row 129 of arduino-restclient/RestClient.cpp at master · csquared/arduino-restclient · GitHub from
write("Connection: close\r\n"); to write("Connection: Keep-Alive\r\n");
Then it worked while keeping the connection open.

In your example of course you have to move the
WiFiClient client; and client.connect(host, httpPort)
before the loop. In the loop you can ask if the client is connected with

client.connected()

and if this is false, open the connection again (but it should stay open if nothing goes wrong).

Have fun,
Klaus

P.S.: Does anybode know how I can make the code-parts lower?