[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] evbuffer_search_eol not finding CRLF?



On Tue, Mar 11, 2014 at 5:56 PM, Jeffrey Walton <noloader@xxxxxxxxx> wrote:
> 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?

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 majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.