Discussion:
evbuffer_search_eol not finding CRLF?
(too old to reply)
Jeffrey Walton
2014-03-11 21:56:18 UTC
Permalink
Raw Message
I'm using the following to connect to my server:

$ printf "GET / HTTP/1.0 \r\n\r\n" | openssl s_client -connect localhost:8443

19 bytes are read in the callback, and that's the length of the string
in the printf above.

But the following is returning -1 for pos:

size_t len = 0;

evbuffer_ptr loc;
memset(&loc, 0x00, sizeof(loc));

evbuffer* c_buf = bufferevent_get_input(bev);
ASSERT(c_buf);

loc = evbuffer_search_eol(c_buf, &loc, &len, EVBUFFER_EOL_CRLF);
if (loc.pos == -1)
{
/* No CRLF found */
return 0;
}

Any ideas what I am doing wrong?
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Nick Mathewson
2014-03-12 17:47:35 UTC
Permalink
Raw Message
Post by Jeffrey Walton
$ printf "GET / HTTP/1.0 \r\n\r\n" | openssl s_client -connect localhost:8443
19 bytes are read in the callback, and that's the length of the string
in the printf above.
size_t len = 0;
evbuffer_ptr loc;
memset(&loc, 0x00, sizeof(loc));
evbuffer* c_buf = bufferevent_get_input(bev);
ASSERT(c_buf);
loc = evbuffer_search_eol(c_buf, &loc, &len, EVBUFFER_EOL_CRLF);
if (loc.pos == -1)
{
/* No CRLF found */
return 0;
}
Any ideas what I am doing wrong?
memset(&loc, 0, sizeof(loc)) does not give you a valid evbuffer_ptr
object. To start at the beginning of the buffer, use a NULL pointer
for loc, or use evbuffer_ptr_set() to construct the evbuffer_ptr
properly.

yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Loading...