stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
425 stars 346 forks source link

Why are you using payload in genHttpHeader() when not used? #98

Closed eabase closed 5 years ago

eabase commented 5 years ago

In: https://github.com/stanleyhuangyc/Freematics/blob/master/firmware_v5/sim5360test/sim5360test.ino

    unsigned int genHttpHeader(HTTP_METHOD method, const char* path, bool keepAlive, const char* payload, int payloadSize)
    {
        // generate HTTP header
        char *p = buffer;
        p += sprintf(p, "%s %s HTTP/1.1\r\nUser-Agent: ONE\r\nHost: %s\r\nConnection: %s\r\n",
          method == HTTP_GET ? "GET" : "POST", path, HTTP_SERVER_URL, keepAlive ? "keep-alive" : "close");
        if (method == HTTP_POST) {
          p += sprintf(p, "Content-length: %u\r\n", payloadSize);
        }
        p += sprintf(p, "\r\n\r");
        return (unsigned int)(p - buffer);
}

Why are you including payload, when it is not used? Was there another intention for this?

stanleyhuangyc commented 5 years ago

There is no point. Payload is actually sent in httpSend().