You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
app: http: Handle "Connection: close" header in HTTP response
Add <connection_close> field to #XHTTPCSTAT URC to indicate when
the server signals connection closure via the "Connection: close"
header.
XHTTPCSTAT: <handle>,<status_code>,<bytes>,<connection_close>
When <connection_close> is set, the host must close and reopen the
socket before sending the next request.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
@@ -144,6 +144,10 @@ The notification line is terminated with ``\r\n`` and the raw body bytes follow
144
144
On successful completion, failure, or timeout, it contains the total number of response body bytes received by the HTTP client.
145
145
For chunked transfer encoding this includes the raw framing bytes (chunk-size lines, ``\r\n`` separators, and the final ``0\r\n\r\n`` terminator).
146
146
On cancel (``status_code=-1`` from ``AT#XHTTPCCANCEL``), it contains the number of response body bytes already delivered to the host.
147
+
* The ``<connection_close>`` parameter is an integer.
148
+
It is ``1`` when the server included a ``Connection: close`` header in its response, indicating that the TCP connection will be closed after this response.
149
+
It is ``0`` otherwise (keep-alive connection).
150
+
When ``<connection_close>`` is ``1``, the host must close the socket with ``AT#XCLOSE`` and open a new connection before issuing the next request.
147
151
148
152
.. note::
149
153
@@ -169,7 +173,7 @@ HTTP GET (automatic mode):
169
173
#XHTTPCDATA: 0,0,261
170
174
<261 bytes>
171
175
172
-
#XHTTPCSTAT: 0,200,261
176
+
#XHTTPCSTAT: 0,200,261,0
173
177
174
178
HTTP GET (manual mode):
175
179
@@ -186,7 +190,7 @@ HTTP GET (manual mode):
186
190
<261 bytes>
187
191
OK
188
192
189
-
#XHTTPCSTAT: 0,200,261
193
+
#XHTTPCSTAT: 0,200,261,0
190
194
191
195
HTTP POST with JSON body and custom header:
192
196
@@ -203,10 +207,12 @@ HTTP POST with JSON body and custom header:
203
207
#XHTTPCDATA: 0,0,432
204
208
<432 bytes>
205
209
206
-
#XHTTPCSTAT: 0,200,432
210
+
#XHTTPCSTAT: 0,200,432,0
207
211
208
212
HTTP GET with Range header (``body_len=0`` is required as a placeholder when headers follow a GET):
209
213
214
+
In this example the server returns ``connection_close=1``, so the host must close and reopen the socket before the next request.
215
+
210
216
::
211
217
212
218
AT#XHTTPCREQ=0,<url>,0,1,0,"Range: bytes=0-127"
@@ -218,7 +224,7 @@ HTTP GET with Range header (``body_len=0`` is required as a placeholder when hea
218
224
#XHTTPCDATA: 0,0,128
219
225
<128 bytes>
220
226
221
-
#XHTTPCSTAT: 0,206,128
227
+
#XHTTPCSTAT: 0,206,128,0
222
228
223
229
AT#XHTTPCREQ=0,<url>,0,1,0,"Range: bytes=128-255"
224
230
#XHTTPCREQ: 0
@@ -229,7 +235,7 @@ HTTP GET with Range header (``body_len=0`` is required as a placeholder when hea
229
235
#XHTTPCDATA: 0,0,128
230
236
<128 bytes>
231
237
232
-
#XHTTPCSTAT: 0,206,128
238
+
#XHTTPCSTAT: 0,206,128,1
233
239
234
240
235
241
HTTP HEAD (no body — ``#XHTTPCSTAT`` follows immediately after ``#XHTTPCHEAD``):
@@ -242,7 +248,7 @@ HTTP HEAD (no body — ``#XHTTPCSTAT`` follows immediately after ``#XHTTPCHEAD``
242
248
243
249
#XHTTPCHEAD: 0,200,261
244
250
245
-
#XHTTPCSTAT: 0,200,0
251
+
#XHTTPCSTAT: 0,200,0,0
246
252
247
253
HTTP POST with chunked response (``content_length=-1``):
248
254
@@ -259,7 +265,7 @@ HTTP POST with chunked response (``content_length=-1``):
@@ -412,7 +418,7 @@ The timer resets each time data is sent or received:
412
418
* Receiving response headers or body bytes.
413
419
* Pulling a body chunk in manual mode (``AT#XHTTPCDATA``).
414
420
415
-
If no such activity occurs within the configured window, the request is aborted and ``#XHTTPCSTAT: <handle>,-1,<total_bytes>`` is emitted.
421
+
If no such activity occurs within the configured window, the request is aborted and ``#XHTTPCSTAT: <handle>,-1,<total_bytes>,<connection_close>`` is emitted.
416
422
The timeout is enforced by a background timer that fires independently of normal socket poll events, so a server that stalls silently (no TCP RST or FIN) is also detected.
417
423
418
424
HTTP request cancel #XHTTPCCANCEL
@@ -435,7 +441,7 @@ Syntax
435
441
* The ``<handle>`` parameter is an integer.
436
442
It identifies the socket of the request to cancel.
437
443
438
-
An unsolicited ``#XHTTPCSTAT: <handle>,-1,<total_bytes>`` notification is emitted after cancellation, where ``<total_bytes>`` is the number of response body bytes already delivered to the host.
444
+
An unsolicited ``#XHTTPCSTAT: <handle>,-1,<total_bytes>,<connection_close>`` notification is emitted after cancellation, where ``<total_bytes>`` is the number of response body bytes already delivered to the host.
0 commit comments