---
name: "TSHttpParserCreate"
section: "3ts"
platform: "linux"
package: "trafficserver-dev"
version: "9.2.5+ds-0+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/TSHttpParserCreate"
---

# TSHttpParserCreate(3ts)

parse HTTP headers from memory buffers

## NAME

TSHttpParserCreate - parse HTTP headers from memory buffers

## SYNOPSIS

```
#include <ts/ts.h>
```

- ***TSHttpParser* TSHttpParserCreate(void)**

  - **void TSHttpParserClear(*TSHttpParser* parser)**

  - **void TSHttpParserDestroy(*TSHttpParser* parser)**

  - ***TSParseResult* TSHttpHdrParseReq(*TSHttpParser* parser, *TSMBuffer* bufp, *TSMLoc* offset, const char \*\*start, const char \*end)**

  - ***TSParseResult* TSHttpHdrParseResp(*TSHttpParser* parser, *TSMBuffer* bufp, *TSMLoc* offset, const char \*\*start, const char \*end)**

  ## 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.

## 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)](/TSAPI/3ts.md)**

## COPYRIGHT

2026, dev@trafficserver.apache.org
