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
Copy file name to clipboardExpand all lines: nanoFramework.System.Net.Http/Http/System.Net._InputNetworkStreamWrapper.cs
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -323,7 +323,12 @@ public int ReadInternal(byte[] buffer, int offset, int size)
323
323
// then we read into internal buffer.
324
324
if(size<read_buffer_size)
325
325
{
326
-
if(0==RefillInternalBuffer())return0;
326
+
if(0==RefillInternalBuffer())
327
+
{
328
+
// Handle the 'HTTP/1.0' case
329
+
IsDone=IsHttp1_0Completed();
330
+
return0;
331
+
}
327
332
328
333
dataBuffered=m_dataEnd-m_dataStart;
329
334
if(dataBuffered>0)
@@ -341,7 +346,15 @@ public int ReadInternal(byte[] buffer, int offset, int size)
341
346
}
342
347
else// Do not replentish internal buffer. Read rest of data directly
343
348
{
344
-
retVal+=m_Stream.Read(buffer,offset,size);
349
+
intbytesRead=m_Stream.Read(buffer,offset,size);
350
+
retVal+=bytesRead;
351
+
352
+
// Handle the 'HTTP/1.0' case
353
+
if((bytesRead==0)&&IsHttp1_0Completed())
354
+
{
355
+
IsDone=true;
356
+
returnretVal;
357
+
}
345
358
}
346
359
}
347
360
@@ -357,6 +370,20 @@ public int ReadInternal(byte[] buffer, int offset, int size)
357
370
returnretVal;
358
371
}
359
372
373
+
/// <summary>
374
+
/// Returns true if we are in 'HTTP/1.0' mode and the connection has been closed, which marks the end of the body.
375
+
/// </summary>
376
+
/// <remarks>
377
+
/// In 'HTTP/1.0' mode, where the content length is not transmitted in the response header and the server closes the connection to mark the end of the body.
378
+
/// (see: RFC9112, §6.3, point 8, https://www.rfc-editor.org/rfc/rfc9112#name-message-body-length)
379
+
/// </remarks>
380
+
privateboolIsHttp1_0Completed()
381
+
{
382
+
return
383
+
(m_BytesLeftInResponse==-1)&&!m_EnableChunkedDecoding&&// We are in HTTP/1.0 mode
384
+
m_Socket.Poll(1,SelectMode.SelectRead)&&(m_Socket.Available==0);// The socket is disconnected
385
+
}
386
+
360
387
/// <summary>
361
388
/// Impletments Write for the stream.
362
389
/// Since we do not have write buffering, all we do is delegate to the m_Stream.
0 commit comments