File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,21 @@ namespace CefSharp
3636 // / </summary>
3737 property int StatusCode;
3838
39+ // / <summary>
40+ // / The length of the response contents. Defaults to -1, which means unknown length
41+ // / and causes CefSharp to read the response stream in pieces. Thus, setting a length
42+ // / is optional but allows for more optimal response reading.
43+ // / </summary>
44+ property int ContentLength;
45+
3946 // / <summary>
4047 // / URL to redirect to (leave empty to not redirect).
4148 // / </summary>
4249 property String^ RedirectUrl;
4350
4451 SchemeHandlerResponse (SchemeHandlerWrapper* schemeHandlerWrapper)
4552 {
53+ ContentLength = -1 ;
4654 _schemeHandlerWrapper = new CefRefPtr<SchemeHandlerWrapper>(schemeHandlerWrapper);
4755 }
4856
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ namespace CefSharp
6060 _stream = response->ResponseStream ;
6161 _statusCode = response->StatusCode ;
6262 _redirectUrl = toNative (response->RedirectUrl );
63+ _contentLength = response->ContentLength ;
6364
6465 _headers = ToHeaderMap (response->ResponseHeaders );
6566
@@ -75,7 +76,14 @@ namespace CefSharp
7576 response->SetMimeType (_mime_type);
7677 response->SetStatus (_statusCode > 0 ? _statusCode : 200 );
7778 response->SetHeaderMap (_headers);
78- response_length = SizeFromStream ();
79+ if (_contentLength >= 0 )
80+ {
81+ response_length = _contentLength;
82+ }
83+ else
84+ {
85+ response_length = SizeFromStream ();
86+ }
7987 redirectUrl = _redirectUrl;
8088 }
8189
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ namespace CefSharp
2626 CefRefPtr<CefCallback> _callback;
2727 int _statusCode;
2828 CefString _redirectUrl;
29+ int _contentLength;
2930
3031 int SizeFromStream ();
3132
You can’t perform that action at this time.
0 commit comments