Skip to content

Commit 1e53952

Browse files
provegardperlun
authored andcommitted
Added SchemeHandlerResponse.CloseStream, to have SchemeHandlerWrapper close the response stream once it has read all data.
1 parent 68be774 commit 1e53952

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CefSharp/SchemeHandlerResponse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ namespace CefSharp
4848
/// </summary>
4949
property String^ RedirectUrl;
5050

51+
/// <summary>
52+
/// Set to true to close the response stream once it has been read. The default value
53+
/// is false in order to preserve the old CefSharp behavior of not closing the stream.
54+
/// </summary>
55+
property bool CloseStream;
56+
5157
SchemeHandlerResponse(SchemeHandlerWrapper* schemeHandlerWrapper)
5258
{
5359
ContentLength = -1;

CefSharp/SchemeHandlerWrapper.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace CefSharp
6161
_statusCode = response->StatusCode;
6262
_redirectUrl = toNative(response->RedirectUrl);
6363
_contentLength = response->ContentLength;
64+
_closeStream = response->CloseStream;
6465

6566
_headers = ToHeaderMap(response->ResponseHeaders);
6667

@@ -106,13 +107,21 @@ namespace CefSharp
106107
bytes_read = ret;
107108
// must return false when the response is complete
108109
has_data = ret > 0;
110+
if (!has_data && _closeStream)
111+
{
112+
_stream->Close();
113+
}
109114
}
110115

111116
return has_data;
112117
}
113118

114119
void SchemeHandlerWrapper::Cancel()
115120
{
121+
if (!!_stream && _closeStream)
122+
{
123+
_stream->Close();
124+
}
116125
_stream = nullptr;
117126
_callback = nullptr;
118127
}

CefSharp/SchemeHandlerWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace CefSharp
2727
int _statusCode;
2828
CefString _redirectUrl;
2929
int _contentLength;
30+
bool _closeStream;
3031

3132
int SizeFromStream();
3233

0 commit comments

Comments
 (0)