// writeTo31Header is an helper to write a variant dictionary to the given io.Writer
428025
func writeTo4VariantDictionary(w io.Writer, id uint8, data *VariantDictionary) error {
	if data != nil {
		var buffer bytes.Buffer
		if err := binary.Write(&buffer, binary.LittleEndian, data.Version); err != nil {
			return err
		}
		for _, item := range data.Items {
			if err := binary.Write(&buffer, binary.LittleEndian, item.Type); err != nil {
				return err
			}
			if err := binary.Write(&buffer, binary.LittleEndian, item.NameLength); err != nil {
				return err
			}
			if err := binary.Write(&buffer, binary.LittleEndian, item.Name); err != nil {
				return err
			}
			if err := binary.Write(&buffer, binary.LittleEndian, item.ValueLength); err != nil {
				return err
			}
			if err := binary.Write(&buffer, binary.LittleEndian, item.Value); err != nil {
				return err
			}
		}
		if err := binary.Write(&buffer, binary.LittleEndian, []byte{0x00}); err != nil {
			return err
		}

		// Write to original writer
		if err := binary.Write(w, binary.LittleEndian, id); err != nil {
			return err
		}
		if err := binary.Write(w, binary.LittleEndian, uint32(buffer.Len())); err != nil {
			return err
		}
		if err := binary.Write(w, binary.LittleEndian, buffer.Bytes()); err != nil {
			return err
		}
	}
	return nil
}
631722
func (cmd *baseCommand) writeHeader(policy *BasePolicy, readAttr int, writeAttr int, fieldCount int, operationCount int) {
	infoAttr := 0
	if policy.LinearizeRead {
		infoAttr |= _INFO3_LINEARIZE_READ
	}

	if policy.ConsistencyLevel == CONSISTENCY_ALL {
		readAttr |= _INFO1_CONSISTENCY_ALL
	}

	// Write all header data except total size which must be written last.
	cmd.dataBuffer[8] = _MSG_REMAINING_HEADER_SIZE // Message header length.
	cmd.dataBuffer[9] = byte(readAttr)
	cmd.dataBuffer[10] = byte(writeAttr)
	cmd.dataBuffer[11] = byte(infoAttr)

	for i := 12; i < 26; i++ {
		cmd.dataBuffer[i] = 0
	}
	cmd.dataOffset = 26
	cmd.WriteInt16(int16(fieldCount))
	cmd.WriteInt16(int16(operationCount))
	cmd.dataOffset = int(_MSG_TOTAL_HEADER_SIZE)
}
1204564
func (f *SourceFile) WriteHeader(title, pack string, imports []*ImportSpec) error {
	ctx := map[string]interface{}{
		"Title":       title,
		"ToolVersion": version.String(),
		"Pkg":         pack,
		"Imports":     imports,
	}
	if err := headerTmpl.Execute(f, ctx); err != nil {
		return fmt.Errorf("failed to generate contexts: %s", err)
	}
	return nil
}
611421
func (t *TablePropExperimenter) WriteTo(w io.Writer) (int64, error) {
	header := tableProp{t.Type(), uint16(tablePropLen + len(t.Data) + 8)}
	padding := makePad(int(header.Len))

	return encoding.WriteTo(w, header, t.Experimenter,
		t.ExpType, t.Data, padding)
}
448086
func (header *Header) WriteTo(w io.Writer) (int64, error) {
	switch header.Version {
	case 1:
		return header.writeVersion1(w)
	case 2:
		return header.writeVersion2(w)
	default:
		return 0, ErrUnknownProxyProtocolVersion
	}
}
508276
func (w *minifyResponseWriter) WriteHeader(status int) {
	w.ResponseWriter.Header().Del("Content-Length")
	w.ResponseWriter.WriteHeader(status)
}
748789
func (h *ExtendedHeader) Write(b *bytes.Buffer, ver protocol.VersionNumber) error {
	if h.IsLongHeader {
		return h.writeLongHeader(b, ver)
	}
	return h.writeShortHeader(b, ver)
}
1167081
func (r *Response) WriteHeader(code int) {
	r.code = code
	r.rw.WriteHeader(code)
}
227795
func (r *ResponseRecorder) WriteHeader(status int) {
	r.status = status
	r.ResponseWriterWrapper.WriteHeader(status)
}
633762
func (w *ResponseWriter) WriteHeader(status int) {
	if w.wroteHeader {
		return
	}

	if w.Header().Get("Content-Type") == "" {
		w.Header().Set("Content-Type", "text/plain; charset=utf8")
	}

	w.out.StatusCode = status

	h := make(map[string]string)

	for k, v := range w.Header() {
		if len(v) > 0 {
			h[k] = v[len(v)-1]
		}
	}

	w.out.Headers = h
	w.wroteHeader = true
}
301212
func writeHeader(b *bytes.Buffer, header map[string][]string) {
	if len(header) == 0 {
		b.WriteString("   (no headers)\n")
		return
	}
	keys := make([]string, 0, len(header))
	// Alphabetize the headers
	for k := range header {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		// Redact the value of any Authorization header to prevent security information from persisting in logs
		value := interface{}("REDACTED")
		if !strings.EqualFold(k, "Authorization") {
			value = header[k]
		}
		fmt.Fprintf(b, "   %s: %+v\n", k, value)
	}
}
1322941
func (w *wrapper) WriteHeader(code int) {
	w.status = code
	w.ResponseWriter.WriteHeader(code)
}
511216
func NewAuthHeaderWriterTo(token, payload []byte, signer Signer) io.WriterTo {
	return &authHeaderWriterTo{token, payload, signer}
}
775720
func WriteV1Header(h *tar.Header, w io.Writer) {
	for _, elem := range v1TarHeaderSelect(h) {
		w.Write([]byte(elem[0] + elem[1]))
	}
}
582851
func (w *responseWriter) WriteHeader(code int) {
	w.status = code
	w.started = true
	w.writer.WriteHeader(code)
}
782495
func (crw *customResponseWriter) WriteHeader(code int) {
	if crw.written {
		LOGHANDLER.Warn(errMultiHeaderWrite)
		return
	}

	crw.statusCode = code
	crw.ResponseWriter.WriteHeader(code)
}
405623
func (builder *MultipartBuilder) WriteFileHeader(partName string, fileHeader *multipart.FileHeader) error {
	file, err := fileHeader.Open()
	if err != nil {
		return err
	}
	defer file.Close()
	return builder.WriteFileReader(partName, fileHeader.Filename, file)
}