code: func responseFormat(acceptHeader string) (Format, *protocolError) {
  	if acceptHeader == "" {
  		return FormatBinary, nil
  	}
  
  	parsed, err := parseAccept(acceptHeader)
  	if err != nil {
  		return FormatBinary, errorf(http.StatusBadRequest, "Accept header: %s", err)
  	}
  	formats := make(acceptFormatSlice, 0, len(parsed))
  	for _, at := range parsed {
  		f, err := FormatFromMediaType(at.MediaType, at.MediaTypeParams)
  		if err != nil {
  			// Ignore invalid format. Check further.
  			continue
  		}
  		formats = append(formats, acceptFormat{f, at.QualityFactor})
  	}
  	if len(formats) == 0 {
  		return FormatBinary, errorf(
  			http.StatusNotAcceptable,
  			"Accept header: specified media types are not not supported. Supported types: %q, %q, %q, %q.",
  			FormatBinary.MediaType(),
  			FormatJSONPB.MediaType(),
  			FormatText.MediaType(),
  			ContentTypeJSON,
  		)
  	}
  	sort.Sort(formats) // order by quality factor and format preference.
  	return formats[0].Format, nil
  }
docs: // responseFormat returns the format to be used in a response.
  // Can return only FormatBinary (preferred), FormatJSONPB or FormatText.
  // In case of an error, format is undefined.