A9G module issue with http request

I am trying to make HTTP request from A9G gps/gsm module but can't get the response.

I've also connected Arduino to A9g for sending AT commands in more convenient way.

This is the code:

/*
  It sends CIPSTART command by typing '@' character in serial
  and then waits for successful connection to send HTTP headers
*/

boolean start = false;
boolean string_complete = false;
String input_string = "";

void setup() {
  Serial1.begin(115200); // A9G serial
  Serial.begin(115200); // Arduino serial
}

void loop() {
  
  if(Serial.available() > 0){
    while(Serial.available() > 0){
      char x = Serial.read();
      if (x == '*'){
        Serial1.print((char)26);
      }
      else if (x == '@') {
        Serial1.print("AT+CIPSTART=\"TCP\",\"mujkotel.wz.cz\",80");
        start = true; // start TCP command trigger
      }
      else{
        Serial1.print(x);
      }
    }
  }

  if(Serial1.available() > 0){
    while(Serial1.available() > 0){
      char z = Serial1.read();
      Serial.print(z);

      if (z == '\n') { // wait for new line from A9G serial
        string_complete = true;
      } else {
        if (string_complete) {
          string_complete = false; // reset new line trigger
          input_string = ""; // clear previous string
        }
        input_string += z; // add characters to current string
      }

      if (string_complete) {
        int match = input_string.indexOf("CONNECT OK"); // wait for successful TCP connection from A9G
        if (match > -1) {

          if (start) { // if TCP was initiated before
            delay(1000);
            Serial1.print("AT+CIPSEND\r\n");
            delay(500);
            Serial1.print("GET /index.html HTTP/1.1\r\n");
            Serial1.print("Host: mujkotel.wz.cz\r\n");
            Serial1.print("   \r\n");
            Serial1.print("   \r\n");

            Serial1.print((char)26);
            start = false;
          }
        }
      }
    }
  }
}

As a result I get this:

AT+CSQ

+CSQ: 27,99

OK
AT+CGATT=1

+CGATT:1

OK
AT+CIPSTART="TCP","mujkotel.wz.cz",80

CONNECT OK

OK
AT+CIPSEND

> GET /index.html HTTP/1.1
Host: mujkotel.wz.cz
   
   

OK

It writes that connection is OK and headers are sent and then it should receive response but it doesn't.

Once typing manually all these commands I've had incomming response but only a part of HTML page and then A9G module rebooted itself suddenly. HTTP headers were the same.

This code is based on erniee's post in this topic

Could someone provide a working example of HTTP request via AT commands with A6/A7/A9 modules, please? I can't find enough examples on the internet. Original docs are insufficient unfortunately.

Any advice will be appreciated, thanks!

what's this?

            Serial1.print("   \r\n");
            Serial1.print("   \r\n");

why do you have spaces in there ? your GET request should end with an empty line

These are two lines with spaces.

There are \r\n characters in the end of the last line which means new empty line after all HTTP stuff.
And then it sends (char)26 which is CTRL+Z command for completion of HTTP request.

Or do you mean that I should add one more end of line?

Serial1.print("   \r\n"); // <- a few spaces here
Serial1.print("   \r\n"); // <- more spaces
Serial1.print("\r\n"); // <- just end of line
Serial1.print((char)26); // <- execute HTTP request

This code is based on Erniee’s post

Serial1.print("   \r\n"); // <- a few spaces here
Serial1.print("   \r\n"); // <- more spaces

The question was, and is, WHY are there ANY spaces?

Just for giggles, try NOT sending the spaces.

WHY are there ANY spaces?

May it cause any problems? I've just repeated Ernie's command queue since it worked for him.

try NOT sending the spaces.

Anyway it doesn't work without spaces.

I've tried different examples (1 2) of HTTP requests w/o success.

I just can't find any working explicit example of HTTP request via AT commands. Could you provide any help?

What did you mean with “without space” - you need the empty line but you don’t need the space (by definition an empty line needs to be… empty).

Post code

I have similar problem;

After GET with "at+cipsend" request to the server, receiving only response header with 200 code but can not get body of server response.

+CIPRCV:311,HTTP/1.1 200
Server: nginx
Date: Wed, 08 Ja

How can I get body response? (please note that only a part of header retrieved.)