Arduino Uno, WiFly and scrambled headers

So im sending a GET request to my arduino server where i try to parse it to get the arguments. But what happens is that the heders get scrambeled, heres one example:

GET /&callback=jQuery1710012618871172890067_1341092772247?537.1zip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Looks like there is part of it missing, but this is random, sometimes there is nothing missing but everything is just on one line..

Heres my arduino code: gist:3025646 · GitHub

So any ideas what should i do to fix this?

String readString = String(100);
String teststring = String(100);
String finalstring = String(100);

readString, testString, and finalString are being assigned initial values of "100". How is this a useful initial value?

If you mean to set an initial size for the String, then, you don't need to be using the String class at all. Use strings (NULL terminated array of chars) instead, and considerably reduce you code size and SRAM usage.

  WiFlyClient client = server.available();
  delay(100);
  if (client) {

Of what possible value is the delay()?

        if (readString.length() < 100) {
          //store characters to string
          readString.concat(c);
        }

This confirms that String is absolutely the wrong choice. Get rid of it, and use strings instead.

PaulS:

  WiFlyClient client = server.available();

delay(100);
 if (client) {



Of what possible value is the delay()?

Here's the topic about the delay in that spot: http://arduino.cc/forum/index.php/topic,111971.0.html

About the rest, yes the code needs some refactoring but im sure these things are not the issue in this case.. or i may be wrong :smiley:

Here's the topic about the delay in that spot:

You mean this part?
So if anybody having similar problems then adding

delay(200);

before

WiFlyClient client = server.available();

then everything should work just fine.

Well, you are right again, but it seems that it wont matter where exactly the delay(); is (before or after), without it the code just wont run.

So PaulS you think this delay() might be the problem?

So PaulS you think this delay() might be the problem?

No. I think these lines are:

String readString = String(100);
String teststring = String(100);
String finalstring = String(100);