github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/http/header-transfer-encoding.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package http
     4  
     5  import "strings"
     6  
     7  // TransferEncoding return transfer encoding and notify if multiple exist
     8  // To read multiple just call this method in a loop to get multiple became false
     9  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
    10  func (h *header) TransferEncoding() (te string, multiple bool) {
    11  	var transferEncoding = h.Get(HeaderKeyTransferEncoding)
    12  	var commaIndex int = strings.IndexByte(transferEncoding, Comma)
    13  	if commaIndex == -1 {
    14  		commaIndex = len(transferEncoding)
    15  	} else {
    16  		h.Replace(HeaderKeyTransferEncoding, transferEncoding[commaIndex+1:])
    17  		multiple = true
    18  	}
    19  	te = transferEncoding[:commaIndex]
    20  	return
    21  }
    22  
    23  // SetTransferEncoding set transfer encoding.
    24  func (h *header) SetTransferEncoding(te string) {
    25  	h.Set(HeaderKeyTransferEncoding, te)
    26  }