File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments