socket/ws/ws_connection.c
/* true if frame length is detected and buffer was resized, false else */
true if frame length is detected and buffer was resized, false else
true if frame length is detected and buffer was resized false else
static bool
WebsocketsFrame_parse_length(Websockets* ws)
{
	size_t nused = StringBuffer_used(ws->in);
	size_t nheader_without_masking_key = ws->frame.payload_offset;
	if (ws->frame.masked)
		nheader_without_masking_key -= WS_MASKING_KEY_LENGTH;
	if (nused < nheader_without_masking_key)
	{
		XDBG("Frame to small to parse payload size");
		return false;
	}
	else
	{
		WebsocketsFrame_parse_payload_length_extended(&ws->frame, StringBuffer_value(ws->in));
		if (StringBuffer_length(ws->in) >= ws->frame.length)
		{
			XDBG("Buffer is large enough for frame");
			return true;
		}
		else
		{
			assert(ws->frame.length < SIZE_MAX);
			return StringBuffer_make_room(ws->in, 0, (size_t)ws->frame.length);
		}
	}
}
static bool WebsocketsFrame_parse_length ( Websockets * ws ) { size_t nused = StringBuffer_used ( ws -> in ) ; size_t nheader_without_masking_key = ws -> frame . payload_offset ; if ( ws -> frame . masked ) nheader_without_masking_key -= WS_MASKING_KEY_LENGTH ; if ( nused < nheader_without_masking_key ) { XDBG ( " " ) ; return false ; } else { WebsocketsFrame_parse_payload_length_extended ( & ws -> frame , StringBuffer_value ( ws -> in ) ) ; if ( StringBuffer_length ( ws -> in ) >= ws -> frame . length ) { XDBG ( " " ) ; return true ; } else { assert ( ws -> frame . length < SIZE_MAX ) ; return StringBuffer_make_room ( ws -> in , 0 , ( size_t ) ws -> frame . length ) ; } } }
true if frame length is detected and buffer was resized, false else
true if frame length is detected and buffer was resized false else