Using YunClient as a web client

I am trying to read data from a server using YunClient.

I was able to get this working using the Yun's HttpClient, but I need to move to something closer to EthernetClient so I can make something that will work more generally with different devices.

Here is the working HttpClient sketch:

 #include <Bridge.h>
#include <HttpClient.h>

HttpClient myClient;
char* myUrl = {"http://www.brainjar.com/java/host/test.html"};

void setup() {
 Serial.begin(9600);
 Bridge.begin();
 while(!Serial);
 
}

void loop() {
  call(myUrl, myClient);
  delay(5000);
}

void call(char* URL, HttpClient inClient){
  inClient.get(URL);
  while (inClient.available()) 
      {  
      Serial.print((char)inClient.read());
      }
}

Here is my attempt to get the same functionality using YunClient
I am hoping to be able to read the contents of the site in the serial monitor:

#include <Bridge.h>
#include <YunClient.h>

YunClient myClient;
//this url works:
char* myUrl = {"www.brainjar.com"};
//this won't work:
char* myUrl2 = {"www.brainjar.com/java/host/test"};

void setup() {
 Serial.begin(9600);
 Bridge.begin();
 while(!Serial);
}

void loop() {
  connectTest(myUrl, myClient);
  call(myUrl, myClient);
  call2(myUrl, myClient);
  delay(5000);
}

void connectTest(char* URL, YunClient inClient){
  Serial.println(inClient.connect(URL, 80));
  Serial.println(inClient.available());
}

//client.available() always returns 0
void call(char* URL, YunClient inClient){
  inClient.connect(URL, 80);
  while(inClient.available()){
      Serial.print((char)inClient.read());
  }    
}
//client.read() only prints junk
void call2(char* URL, YunClient inClient){
  inClient.connect(URL, 80);
  for(int i = 0; i < 20; i++){
      Serial.print((char)inClient.read());
  }    Serial.println();
}

Any help is much appreciated

Is the problem trying to use YunClient directly as an HttpClient, which it is too low-level to do?

The second url not working would make sense, since only the base ip address would be resolved if I understand, but I am still not sure why client.available() never returns 1.

solved

#include <Bridge.h>
#include <YunClient.h>


byte server[] = { 64, 233, 187, 99 }; // Google
char server2[] = {"www.brainjar.com"};
char location[] = {"/java/host/test.html"};

YunClient client;

void setup()
{
  Bridge.begin();
  Serial.begin(9600);
  while(!Serial);
}

void loop()
{
    //test(server, client);
    test2(server2, location, client);
    delay(5000);
}

void test(byte url[], YunClient inclient){

   if (inclient.connect(url, 80)) {
    Serial.println("connected");
  
    inclient.println(F("GET /search?q=arduino HTTP/1.0"));
  
    inclient.println(); 
    
    delay(1000); //<<<importnant
  } else {
    Serial.println("connection failed");
  }
  
  while(inclient.available()) {
    char c = inclient.read();
    Serial.print(c);
  }
  //add reconnect routine...
  
}

void test2(char url[], char loc[], YunClient inclient){

   if (inclient.connect(url, 80)) {
    Serial.println("connected");
  
    inclient.print("GET "); 
    inclient.print(loc); 
    inclient.println(); 
    
    delay(1000); //<<<importnant
  } else {
    Serial.println("connection failed");
  }
  
  while(inclient.available()) {
    char c = inclient.read();
    Serial.print(c);
  }
  //add reconnect routine...
  
}