Extracting the body from a POST request in when using the HTTPS Client project

Hello, 

I am trying to use the HTTPS client code to make a personalized request to my server. The data returned in the post request is printed using the default buffer specified for reception - 'recv_buf' as follows:

do {
bytes = recv(fd, &recv_buf[off], RECV_BUF_SIZE - off, 0);
if (bytes < 0) {
printk("recv() failed, err %d\n", errno);
}
off += bytes;
} while (bytes != 0 /* peer closed connection */);

printk("Received %d bytes\n", off);
printk("Received data is %s\n", recv_buf);

In the following case, the data contained in 'recv_buf' has the headers and the body of the POST request. Is there a way to extract the body of the response received to the POST request in nRF9160. The response or content of 'recv_buf' is as follows:

Received data is HTTP/1.1 200 OK



Server: nginx/1.13.3



Date: Mon, 25 Oct 2021 12:55:38 GMT



Content-Type: application/json



Content-Length: 169



Connection: close



Vary: Accept, Accept-Language, Cookie, Origin



Allow: POST, OPTIONS



X-Frame-Options: SAMEORIGIN



Content-Language: en-us



Access-Control-Allow-Origin: *



Access-Control-Allow-Methods: GET, POST, OPTIONS



Access-Control-Allow-Headers: DNT,Authorization, User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range



Access-Control-Expose-Headers: Content-Length,Content-Range






{"
sha_256_key":"703a98fab88564588a5ea83edb65da9278fad98a87b8abc04d18efde0c1e33d1","file_link":"glasschair.s3.amazonaws.com/.../app_update.bin
"}


It would be extremely helpful if you could help me with a way to remove all the headers and only extract the part within the braces i.e. the actual data/body of the response for further use in the code.

Thanks and Regards,

Siddhant

Parents Reply Children
No Data
Related