// formatUserAgent formats an AppInfo in a way that's suitable to be appended
// to a User-Agent string. Note that this format is shared between all
// libraries so if it's changed, it should be changed everywhere.
170420
func (a *AppInfo) formatUserAgent() string {
	str := a.Name
	if a.Version != "" {
		str += "/" + a.Version
	}
	if a.URL != "" {
		str += " (" + a.URL + ")"
	}
	return str
}
667015
func (adm *AdminClient) SetAppInfo(appName string, appVersion string) {
	// if app name and version is not set, we do not a new user
	// agent.
	if appName != "" && appVersion != "" {
		adm.appInfo.appName = appName
		adm.appInfo.appVersion = appVersion
	}
}
1336175
func FormatAppResource(res resource.Resource) FormattedAppResource {
	used := !res.IsPlaceholder()
	result := FormattedAppResource{
		ID:               res.ID,
		ApplicationID:    res.ApplicationID,
		Name:             res.Name,
		Type:             res.Type.String(),
		Path:             res.Path,
		Description:      res.Description,
		Origin:           res.Origin.String(),
		Fingerprint:      res.Fingerprint.String(),
		Size:             res.Size,
		Used:             used,
		Timestamp:        res.Timestamp,
		Username:         res.Username,
		CombinedRevision: combinedRevision(res),
		CombinedOrigin:   combinedOrigin(used, res),
		UsedYesNo:        usedYesNo(used),
	}
	// Have to check since revision 0 is still a valid revision.
	if res.Revision >= 0 {
		result.Revision = fmt.Sprintf("%v", res.Revision)
	} else {
		result.Revision = "-"
	}
	return result
}
470941
func (p *UserAgent) Browser() (string, string) {
	return p.browser.Name, p.browser.Version
}
347239
func (h *DatabaseBackupHistory) FormatCreatedAt(layout string) string {
	return h.CreatedAt.Format(layout)
}
975440
func Convert_v1_UserAgentMatchingConfig_To_config_UserAgentMatchingConfig(in *v1.UserAgentMatchingConfig, out *config.UserAgentMatchingConfig, s conversion.Scope) error {
	return autoConvert_v1_UserAgentMatchingConfig_To_config_UserAgentMatchingConfig(in, out, s)
}
779155
func OperaUserAgent() string {
	platform := "(" + randomPlatform() + "; en-US) Presto/2." + strconv.Itoa(randIntRange(8, 13)) + "." + strconv.Itoa(randIntRange(160, 355)) + " Version/" + strconv.Itoa(randIntRange(10, 13)) + ".00"

	return "Opera/" + strconv.Itoa(randIntRange(8, 10)) + "." + strconv.Itoa(randIntRange(10, 99)) + " " + platform
}
321099
func (r *Request) SetUserAgent(useragent string) *Request {
	r.setting.UserAgent = useragent
	return r
}
220554
func ServeFormatted(w http.ResponseWriter, r *http.Request, v interface{}) {
	accept := r.Header.Get("Accept")
	switch accept {
	case applicationJson:
		ServeJson(w, v)
	case applicationXml, textXml:
		ServeXml(w, v)
	default:
		ServeJson(w, v)
	}

	return
}
1034034
func (s *ExtendedStatsBucketAggregation) Format(format string) *ExtendedStatsBucketAggregation {
	s.format = format
	return s
}
497817
func getUserAgentFromContext(ctx context.Context) string {
	var upstreamUA string
	if ctx != nil {
		var ki interface{} = ctx.Value(UAStringKey{})
		if ki != nil {
			upstreamUA = ctx.Value(UAStringKey{}).(string)
		}
	}
	return upstreamUA
}
268006
func (a ReferenceAction) Format(buf *TrackedBuffer) {
	switch a {
	case Restrict:
		buf.WriteString("restrict")
	case Cascade:
		buf.WriteString("cascade")
	case NoAction:
		buf.WriteString("no action")
	case SetNull:
		buf.WriteString("set null")
	case SetDefault:
		buf.WriteString("set default")
	}
}
575685
func (c *Config) WithUserAgent(ua string) *Config {
	c.UserAgent = fmt.Sprintf("%s,%s", ua, c.UserAgent)
	return c
}
1207830
func AddToUserAgent(extension string) error {
	if extension != "" {
		ua = fmt.Sprintf("%s %s", ua, extension)
		return nil
	}
	return fmt.Errorf("Extension was empty, User Agent remained as '%s'", ua)
}
966905
func loadAgentFile(filename string) (*redditproto.UserAgent, error) {
	buf, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, err
	}

	agent := &redditproto.UserAgent{}
	return agent, proto.UnmarshalText(bytes.NewBuffer(buf).String(), agent)
}
533370
func (u *Unit) AgentPresence() (bool, error) {
	pwatcher := u.st.workers.presenceWatcher()
	if u.ShouldBeAssigned() {
		return pwatcher.Alive(u.globalAgentKey())
	}
	// Units in CAAS models rely on the operator pings.
	// These are for the application itself.
	app, err := u.Application()
	if err != nil {
		return false, errors.Trace(err)
	}
	appAlive, err := pwatcher.Alive(app.globalKey())
	if err != nil {
		return false, errors.Trace(err)
	}
	return appAlive, nil
}
846581
func (s *Http) SetUserAgent(v string) *Http {
	s.UserAgent = &v
	return s
}