[Modify] Polish it

This commit is contained in:
sta 2018-02-21 17:29:16 +09:00
parent ec6bfb9955
commit 9f7ee08295

View File

@ -502,26 +502,34 @@ namespace WebSocketSharp.Net
public RequestStream GetRequestStream (long contentLength, bool chunked) public RequestStream GetRequestStream (long contentLength, bool chunked)
{ {
if (_inputStream != null || _socket == null)
return _inputStream;
lock (_sync) { lock (_sync) {
if (_socket == null) if (_socket == null)
return _inputStream; return _inputStream;
if (_inputStream != null)
return _inputStream;
var buff = _requestBuffer.GetBuffer (); var buff = _requestBuffer.GetBuffer ();
var len = (int) _requestBuffer.Length; var len = (int) _requestBuffer.Length;
disposeRequestBuffer (); disposeRequestBuffer ();
if (chunked) { if (chunked) {
_context.Response.SendChunked = true; _context.Response.SendChunked = true;
_inputStream = _inputStream = new ChunkedRequestStream (
new ChunkedRequestStream (_stream, buff, _position, len - _position, _context); _stream, buff, _position, len - _position, _context
} );
else {
_inputStream = return _inputStream;
new RequestStream (_stream, buff, _position, len - _position, contentLength);
} }
_inputStream = new RequestStream (
_stream,
buff,
_position,
len - _position,
contentLength
);
return _inputStream; return _inputStream;
} }
} }