From 9f7ee0829596bf399e0798a6425c2a670614285d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2018 17:29:16 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 44fb84b9..60df3f7b 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -502,26 +502,34 @@ namespace WebSocketSharp.Net public RequestStream GetRequestStream (long contentLength, bool chunked) { - if (_inputStream != null || _socket == null) - return _inputStream; - lock (_sync) { if (_socket == null) return _inputStream; + if (_inputStream != null) + return _inputStream; + var buff = _requestBuffer.GetBuffer (); var len = (int) _requestBuffer.Length; disposeRequestBuffer (); + if (chunked) { _context.Response.SendChunked = true; - _inputStream = - new ChunkedRequestStream (_stream, buff, _position, len - _position, _context); - } - else { - _inputStream = - new RequestStream (_stream, buff, _position, len - _position, contentLength); + _inputStream = new ChunkedRequestStream ( + _stream, buff, _position, len - _position, _context + ); + + return _inputStream; } + _inputStream = new RequestStream ( + _stream, + buff, + _position, + len - _position, + contentLength + ); + return _inputStream; } }