replaceOrAdd(name:value:)

Add a header name/value pair to the block, replacing any previous values for the same header name that are already in the block.

HTTPHeaders+Name.swift:455
mutating func replaceOrAdd(name: Name, value: String)

Parameters

name

The header field name. For maximum compatibility this should be an ASCII string. For future-proofing with HTTP/2 lowercase header names are strongly

value

The header field value to add for the given name.

This is a supplemental method to add that essentially combines remove and add in a single function. It can be used to ensure that a header block is in a well-defined form without having to check whether the value was previously there. Like add, this method performs case-insensitive comparisons of the header field names.