logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

TSHttpParserCreate - parse HTTP headers from memory buffers

Description

TSHttpParserCreate()  creates  an  HTTP  parser  object. The parser's data structure contains information
       about  the  header  being  parsed.  A  single  HTTP  parser  can  be  used  multiple  times,  though  not
       simultaneously. Before being used again, the parser must be cleared by calling TSHttpParserClear().

       TSHttpHdrParseReq()  parses  an  HTTP request header. The HTTP header offset must already be created, and
       must reside inside the marshal buffer bufp. The start argument points to  the  current  position  of  the
       string  buffer  being  parsed  and  the end argument points to one byte after the end of the buffer to be
       parsed. On return, start is modified to point past the last character parsed.

       It is possible to parse an HTTP request  header  a  single  byte  at  a  time  using  repeated  calls  to
       TSHttpHdrParseReq().  As  long  as an error does not occur, the TSHttpHdrParseReq() function will consume
       that   single   byte   and   ask   for    more.    TSHttpHdrParseReq()    should    be    called    after
       TS_HTTP_READ_REQUEST_HDR_HOOK.

       TSHttpHdrParseResp() operates in the same manner as TSHttpHdrParseReq() except it parses an HTTP response
       header.  It should be called after TS_HTTP_READ_RESPONSE_HDR_HOOK.

       TSHttpParserClear() clears the specified HTTP parser so it may be used again.

       TSHttpParserDestroy()  destroys the TSHttpParser object pointed to by parser. The parser pointer must not
       be NULL.

Name

       TSHttpParserCreate - parse HTTP headers from memory buffers

Return Values

TSHttpHdrParseReq() and  TSHttpHdrParseResp()  both  return  a  TSParseResult  value.  TS_PARSE_ERROR  is
       returned  on  error,  TS_PARSE_CONT  is  returned if parsing of the header stopped because the end of the
       buffer was reached, and TS_PARSE_DONE when a \r\n\r\n pattern is encountered, indicating the end  of  the
       header.

See Also

TSAPI(3ts)

Synopsis

          #include <ts/ts.h>

       TSHttpParserTSHttpParserCreate(void)voidTSHttpParserClear(TSHttpParserparser)voidTSHttpParserDestroy(TSHttpParserparser)TSParseResultTSHttpHdrParseReq(TSHttpParserparser,TSMBufferbufp,TSMLocoffset,constchar**start,constchar*end)TSParseResultTSHttpHdrParseResp(TSHttpParserparser,TSMBufferbufp,TSMLocoffset,constchar**start,constchar*end)

See Also