This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AT#XHTTPCREQ serial_lte_modem does not handle chunked HTTP response

if a response to the http request is chunked (https://en.wikipedia.org/wiki/Chunked_transfer_encoding), it is not handled correctly by the serial_lte_modem.

Sometimes - e.g. if cloudflare is used, it is not possible to disable chunk encoding, so the serial_lte_modem app is unusable in these scenarios.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
00> [00:03:22.707,031] <inf> httpc: Partial data received (743 bytes)
00> [00:03:22.707,061] <inf> httpc: All the data received (743 bytes)
00> [00:03:22.707,489] <inf> at_host: TX
00> 23 58 48 54 54 50 43 52 53 50 3a 37 34 33 2c 30 |#XHTTPCR SP:743,0
00> 0d 0a |..
00> [00:03:22.709,625] <inf> at_host: TX
00> 22 7d 5d 2c 22 67 72 6f 75 70 22 3a 22 63 66 2d |"}],"gro up":"cf-
00> 6e 65 6c 22 2c 22 6d 61 78 5f 61 67 65 22 3a 36 |nel","ma x_age":6
00> 30 34 38 30 30 7d 0d 0a 4e 45 4c 3a 20 7b 22 72 |04800}.. NEL: {"r
00> 65 70 6f 72 74 5f 74 6f 22 3a 22 63 66 2d 6e 65 |eport_to ":"cf-ne
00> 6c 22 2c 22 6d 61 78 5f 61 67 65 22 3a 36 30 34 |l","max_ age":604
00> 38 30 30 7d 0d 0a 53 65 72 76 65 72 3a 20 63 6c |800}..Se rver: cl
00> 6f 75 64 66 6c 61 72 65 0d 0a 43 46 2d 52 41 59 |oudflare ..CF-RAY
00> 3a 20 35 66 31 62 30 35 63 34 39 66 63 35 64 34 |: 5f1b05 c49fc5d4
00> 33 66 2d 48 41 4d 0d 0a 0d 0a 44 65 76 69 63 65 |3f-HAM.. ..Device
00> 20 31 38 32 30 65 66 66 64 20 77 61 73 20 6e 6f | 1820eff d was no
00> 74 20 66 6f 75 6e 64 64 34 39 37 36 63 30 32 39 |t foundd 4976c029
00> 37 37 37 30 38 64 39 66 62 35 36 33 31 30 34 65 |77708d9f b563104e
00> 36 62 30 61 31 31 31 34 31 36 30 35 32 39 37 30 |6b0a1114 16052970
00> 33 34 3b 20 65 78 70 69 72 65 73 3d 53 75 6e 2c |34; expi res=Sun,
00> 20 31 33 2d 44 65 63 2d 32 30 20 31 39 3a 35 30 | 13-Dec- 20 19:50
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Thanks for the update, Michal! Good to hear that there are some progress. I've made the developer aware that the issue with chunks persists and they are working on it!

    Best regards,
    Carl Richard

  • Hi Michal,

    I've added the handling of chunked payload in attached slm_at_httpc.c. Can you try it with your chunked response?

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /*
    * Copyright (c) 2020 Nordic Semiconductor ASA
    *
    * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    */
    #include <logging/log.h>
    #include <zephyr.h>
    #include <stdio.h>
    #include <net/socket.h>
    #include <net/tls_credentials.h>
    #include <net/http_client.h>
    #include <nrf_socket.h>
    #include "slm_at_httpc.h"
    #include "slm_util.h"
    LOG_MODULE_REGISTER(httpc, CONFIG_SLM_LOG_LEVEL);
    #define HTTPC_HOST_LEN 64
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best Regards,

    Larry

  • Hi Larry,

    Thank you for the fix, I'll try it tomorrow and let you know.

    Best Regards, Michal

  • Hi Larry,

    I can confirm that this fix resolves the issue for us. Everything is working as it should now.


    Thank you for your help and your persistance to resolve this issue.

    Best Regards, Michal V.

1 2 3 4