---
name: "TSMimeHdrFieldValueStringSet"
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/TSMimeHdrFieldValueStringSet"
---

# TSMimeHdrFieldValueStringSet(3ts)

TSMimeHdrFieldValueStringSet API function

## NAME

TSMimeHdrFieldValueStringSet - TSMimeHdrFieldValueStringSet API function

## SYNOPSIS

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

- ***TSReturnCode* TSMimeHdrFieldValueStringSet(*TSMBuffer* bufp, *TSMLoc* hdr, *TSMLoc* field, int idx, const char \*value, int length)**

  ## DESCRIPTION

*TSMimeHdrFieldValueStringSet()* sets the value of a MIME field. The field is identified by the combination of *bufp*, *hdr*, and *field* which should match those passed to the function that returned *field* such as *TSMimeHdrFieldFind()*. The *value* is copied to the header represented by *bufp*. *value* does not have to be null terminated (and in general should not be).

If *idx* is non-negative the existing value in the field is treated as a multi-value and *idx* as the 0 based index of which element to set. For example if the field had the value **dave, grigor, tamara** and *TSMimeHdrFieldValueStringSet()* was called with *value* of **syeda** and *idx* of 1, the value would be set to **dave, syeda, tamara**. If *idx* is non-negative it must be the index of an existing element or exactly one past the last element or the call will fail. In the example case *idx* must be between **0** and **3** inclusive. *TSMimeHdrFieldValuesCount()* can be used to get the current number of elements.

This function returns *TS\_SUCCESS* if the value was set, *TS\_ERROR* if not.

## COPYRIGHT

2026, dev@trafficserver.apache.org
