// WriteGetECmd writes out the binary representation of a gete request header to the given io.Writer
541078
func WriteGetECmd(w io.Writer, key []byte, opaque uint32) error {
	//fmt.Printf("GetE: key: %v | totalBodyLength: %v\n", string(key), len(key))
	return writeKeyCmd(w, OpcodeGetE, key, opaque)
}
783017
func (r *gRPCresponse) Write(b []byte) (int, error) {
	r.Msg = new(dns.Msg)
	return len(b), r.Msg.Unpack(b)
}
206203
func (c *Context) CacheWrite(ckey CacheKey, data []byte) {
	if ae != nil {
		ae.CacheWrite(c.ae, ckey.ae, data)
		return
	}
	c.cacheWrite(ckey, data)
}
942141
func Write(config clientcmdapi.Config) ([]byte, error) {
	return runtime.Encode(clientcmdlatest.Codec, &config)
}
200234
func (c *msgpackCodec) Write(m *codec.Message, b interface{}) error {
	switch m.Type {
	case codec.Request:
		h := Request{
			ID:     m.Id,
			Method: m.Endpoint,
			Body:   b,
		}

		return msgp.Encode(c.rwc, &h)

	case codec.Response:
		h := Response{
			ID:   m.Id,
			Body: b,
		}

		h.Error = m.Error

		return msgp.Encode(c.rwc, &h)

	case codec.Publication:
		h := Notification{
			Method: m.Endpoint,
			Body:   b,
		}

		return msgp.Encode(c.rwc, &h)

	default:
		return fmt.Errorf("Unrecognized message type: %v", m.Type)
	}
}
1107440
func writeKeyCmd(w io.Writer, opcode uint8, key []byte, opaque uint32) error {
	// opcode, keyLength, extraLength, totalBodyLength
	header := makeRequestHeader(opcode, len(key), 0, len(key), opaque)
	writeRequestHeader(w, header)

	n, err := w.Write(key)

	metrics.IncCounterBy(common.MetricBytesWrittenLocal, uint64(ReqHeaderLen+n))
	reqHeadPool.Put(header)

	return err
}
795298
func (w *Writer) Write(p []byte) (n int, errRet error) {
	if w.err != nil {
		return 0, w.err
	}
	if !w.wroteHeader {
		copy(w.enc, magicChunk)
		if _, err := w.w.Write(w.enc[:len(magicChunk)]); err != nil {
			w.err = err
			return n, err
		}
		w.wroteHeader = true
	}
	for len(p) > 0 {
		var uncompressed []byte
		if len(p) > maxUncompressedChunkLen {
			uncompressed, p = p[:maxUncompressedChunkLen], p[maxUncompressedChunkLen:]
		} else {
			uncompressed, p = p, nil
		}
		checksum := crc(uncompressed)

		// Compress the buffer, discarding the result if the improvement
		// isn't at least 12.5%.
		chunkType := uint8(chunkTypeCompressedData)
		chunkBody, err := Encode(w.enc, uncompressed)
		if err != nil {
			w.err = err
			return n, err
		}
		if len(chunkBody) >= len(uncompressed)-len(uncompressed)/8 {
			chunkType, chunkBody = chunkTypeUncompressedData, uncompressed
		}

		chunkLen := 4 + len(chunkBody)
		w.buf[0] = chunkType
		w.buf[1] = uint8(chunkLen >> 0)
		w.buf[2] = uint8(chunkLen >> 8)
		w.buf[3] = uint8(chunkLen >> 16)
		w.buf[4] = uint8(checksum >> 0)
		w.buf[5] = uint8(checksum >> 8)
		w.buf[6] = uint8(checksum >> 16)
		w.buf[7] = uint8(checksum >> 24)
		if _, err = w.w.Write(w.buf[:]); err != nil {
			w.err = err
			return n, err
		}
		if _, err = w.w.Write(chunkBody); err != nil {
			w.err = err
			return n, err
		}
		n += len(uncompressed)
	}
	return n, nil
}
468324
func httpGetHeader(h http.Header, key string) string {
	if h == nil {
		return ""
	}
	v := h[key]
	if len(v) == 0 {
		return ""
	}
	return v[0]
}
1336060
func (c *udpAnnounce) write(h *RequestHeader, body interface{}, trailer []byte) (err error) {
	var buf bytes.Buffer
	err = binary.Write(&buf, binary.BigEndian, h)
	if err != nil {
		panic(err)
	}
	if body != nil {
		err = binary.Write(&buf, binary.BigEndian, body)
		if err != nil {
			panic(err)
		}
	}
	_, err = buf.Write(trailer)
	if err != nil {
		return
	}
	n, err := c.socket.Write(buf.Bytes())
	if err != nil {
		return
	}
	if n != buf.Len() {
		panic("write should send all or error")
	}
	return
}
873284
func NewGetCmd(c jujuc.ContextComponent) (*GetCmd, error) {
	return &GetCmd{
		compContext: c,
	}, nil
}
517672
func handleGetPass(r *Request) (interface{}, error) {
	fmt.Print(r.Args.One().MustString())
	data, err := terminal.ReadPassword(int(os.Stdin.Fd())) // stdin
	fmt.Println()
	if err != nil {
		return nil, err
	}
	return string(data), nil
}
1127044
func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) {
	return c.stdout, c.stderr
}
1006592
func (c *Client) HGet(key, member string) (string, error) {
	v, err := c.execWithKey(true, "HGET", key, member)
	if err != nil {
		return "", err
	}
	return iface2str(v)
}
556961
func (c *Client) write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
	r := c.newRequest("PUT", endpoint)
	r.setWriteOptions(q)
	r.obj = in
	rtt, resp, err := requireOK(c.doRequest(r))
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	wm := &WriteMeta{RequestTime: rtt}
	if out != nil {
		if err := decodeBody(resp, &out); err != nil {
			return nil, err
		}
	} else if _, err := ioutil.ReadAll(resp.Body); err != nil {
		return nil, err
	}
	return wm, nil
}
513950
func (d *Decoder) getc() (b byte, ok bool) {
	if d.err != nil {
		return 0, false
	}
	if d.nextByte >= 0 {
		b = byte(d.nextByte)
		d.nextByte = -1
	} else {
		b, d.err = d.r.ReadByte()
		if d.err != nil {
			return 0, false
		}
		if d.saved != nil {
			d.saved.WriteByte(b)
		}
	}
	if b == '\n' {
		d.line++
	}
	return b, true
}
1245767
func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error {
	if s.updateHeaderSent() || s.getState() == streamDone {
		return ErrIllegalHeaderWrite
	}
	s.hdrMu.Lock()
	if md.Len() > 0 {
		if s.header.Len() > 0 {
			s.header = metadata.Join(s.header, md)
		} else {
			s.header = md
		}
	}
	if err := t.writeHeaderLocked(s); err != nil {
		s.hdrMu.Unlock()
		return err
	}
	s.hdrMu.Unlock()
	return nil
}
1067108
func (rm *responseModifier) Write(b []byte) (int, error) {
	if rm.hijacked {
		return rm.rw.Write(b)
	}

	if len(rm.body)+len(b) > maxBufferSize {
		rm.Flush()
	}
	rm.body = append(rm.body, b...)
	return len(b), nil
}