// caasHistoryRewriteDoc determines which status should be stored as history.
503850
func caasHistoryRewriteDoc(jujuStatus, caasStatus status.StatusInfo, expectWorkload bool, displayStatus displayStatusFunc, clock clock.Clock) (*statusDoc, error) {
	modifiedStatus := displayStatus(jujuStatus, caasStatus, expectWorkload)
	if modifiedStatus.Status == jujuStatus.Status && modifiedStatus.Message == jujuStatus.Message {
		return nil, nil
	}
	return &statusDoc{
		Status:     modifiedStatus.Status,
		StatusInfo: modifiedStatus.Message,
		StatusData: utils.EscapeKeys(modifiedStatus.Data),
		Updated:    timeOrNow(modifiedStatus.Since, clock).UnixNano(),
	}, nil
}
681031
func (m *scopedManager) WriteHeader(code int) {
	if m.wroteHeader {
		return
	}
	m.MustSaveAll()
	m.wroteHeader = true
	m.ResponseWriter.WriteHeader(code)
}
824440
func resource2doc(id string, stored storedResource) *resourceDoc {
	res := stored.Resource
	// TODO(ericsnow) We may need to limit the resolution of timestamps
	// in order to avoid some conversion problems from Mongo.
	return &resourceDoc{
		DocID:     id,
		ID:        res.ID,
		PendingID: res.PendingID,

		ApplicationID: res.ApplicationID,

		Name:        res.Name,
		Type:        res.Type.String(),
		Path:        res.Path,
		Description: res.Description,

		Origin:      res.Origin.String(),
		Revision:    res.Revision,
		Fingerprint: res.Fingerprint.Bytes(),
		Size:        res.Size,

		Username:  res.Username,
		Timestamp: res.Timestamp,

		StoragePath: stored.storagePath,
	}
}
725000
func (f *Fetcher) RewriteCAsWithDataUrls(cas []types.CaReference) error {
	for i, ca := range cas {
		blob, err := f.getCABlob(ca)
		if err != nil {
			return err
		}

		cas[i].Source = dataurl.EncodeBytes(blob)
	}
	return nil
}
227795
func (r *ResponseRecorder) WriteHeader(status int) {
	r.status = status
	r.ResponseWriterWrapper.WriteHeader(status)
}
237737
func (a *Application) StatusHistory(filter status.StatusHistoryFilter) ([]status.StatusInfo, error) {
	args := &statusHistoryArgs{
		db:        a.st.db(),
		globalKey: a.globalKey(),
		filter:    filter,
	}
	return statusHistory(args)
}
69600
func (c *OutboundCall) WriteToRequestMeta(ctx context.Context, reqMeta *transport.RequestMeta) (context.Context, error) {
	for _, h := range c.headers {
		reqMeta.Headers = reqMeta.Headers.With(h.k, h.v)
	}

	if c.shardKey != nil {
		reqMeta.ShardKey = *c.shardKey
	}
	if c.routingKey != nil {
		reqMeta.RoutingKey = *c.routingKey
	}
	if c.routingDelegate != nil {
		reqMeta.RoutingDelegate = *c.routingDelegate
	}

	// NB(abg): context and error are unused for now but we want to leave room
	// for CallOptions which can fail or modify the context.
	return ctx, nil
}
32166
func GetDoc(w rest.ResponseWriter, r *rest.Request) {
	id := r.PathParam("id")
	collection := r.PathParam("collection")
	doc, err := get.Get(collection, id)
	if err != nil {
		rest.Error(w, "Not Found", 404)
		return
	}
	w.WriteHeader(http.StatusOK)
	if doc == nil {
		w.(http.ResponseWriter).Write(variables.BlankResponse)
		return
	}
	fmt.Println(doc)
	w.WriteJson(doc)
}
927213
func (r *ResponseRecorder) WriteHeader(status int) {
	r.status = status
	r.ResponseWriter.WriteHeader(status)
}
571470
func WriteTroughCache(dirname string) Cache {
	return &writeTroughCache{
		memory: MemoryCache(),
		file:   FileCache(dirname),
	}
}
572840
func (c *CompressResponseWriter) WriteHeader(status int) {
	if c.closed {
		return
	}
	c.headersWritten = true
	c.prepareHeaders()
	c.Header.SetStatus(status)
}
944507
func (o *GetTaskCommentsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error

	// path param id
	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
		return err
	}

	if o.PageSize != nil {

		// query param pageSize
		var qrPageSize int32
		if o.PageSize != nil {
			qrPageSize = *o.PageSize
		}
		qPageSize := swag.FormatInt32(qrPageSize)
		if qPageSize != "" {
			if err := r.SetQueryParam("pageSize", qPageSize); err != nil {
				return err
			}
		}

	}

	if o.Since != nil {

		// query param since
		var qrSince strfmt.DateTime
		if o.Since != nil {
			qrSince = *o.Since
		}
		qSince := qrSince.String()
		if qSince != "" {
			if err := r.SetQueryParam("since", qSince); err != nil {
				return err
			}
		}

	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
1118054
func UnsafeWriteHeapProfile(ctx *rpctypes.Context, filename string) (*ctypes.ResultUnsafeProfile, error) {
	memProfFile, err := os.Create(filename)
	if err != nil {
		return nil, err
	}
	if err := pprof.WriteHeapProfile(memProfFile); err != nil {
		return nil, err
	}
	if err := memProfFile.Close(); err != nil {
		return nil, err
	}

	return &ctypes.ResultUnsafeProfile{}, nil
}
611386
func (a *AssetsCache) WriteToCache(key *AssetCacheKey, fullContent, content []byte, requires []types.RequireInterface, ExtInfo *types.ExtensionInfo) {
	a.mutex.Lock()
	defer a.mutex.Unlock()
	var assetCaches *assetLru
	var hit bool
	if assetCaches, hit = a.cache[key.AssetPath]; !hit {
		assetCaches = newAssetLru(5)
		a.cache[key.AssetPath] = assetCaches
	}
	assetCaches.Add(key.Key, &assetCache{requires, fullContent, content, ExtInfo, time.Now().Unix()})
}
206203
func (c *Context) CacheWrite(ckey CacheKey, data []byte) {
	if ae != nil {
		ae.CacheWrite(c.ae, ckey.ae, data)
		return
	}
	c.cacheWrite(ckey, data)
}
1252939
func (rl *respLogger) WriteHeader(status int) {
	rl.recordStatus(status)
	rl.w.WriteHeader(status)
}
634376
func getHistoryRewriter(cmd *cobra.Command, db *gitobj.ObjectDatabase, l *tasklog.Logger) *githistory.Rewriter {
	include, exclude := getIncludeExcludeArgs(cmd)
	filter := buildFilepathFilter(cfg, include, exclude)

	return githistory.NewRewriter(db,
		githistory.WithFilter(filter), githistory.WithLogger(l))
}