// Write the content of the favicon, or respond with a 404 not found
// in case of error (hardly a critical error).
421337
func writeBody(w http.ResponseWriter, r *http.Request, buf []byte) {
	_, err := w.Write(buf)
	if err != nil {
		ghost.LogFn("ghost.favicon : error writing response : %s", err)
		http.NotFound(w, r)
	}
}
499731
func (w *ResponseWriter) WriteHeader(statusCode int) {
	w.status = statusCode
	w.ResponseWriter.WriteHeader(statusCode)
}
20784
func (r *ResponseData) Write(b []byte) (int, error) {
	if !r.Written() {
		r.WriteHeader(http.StatusOK)
	}
	r.Length += len(b)
	return r.ResponseWriter.Write(b)
}
22504
func (this *statusResponseWriter) Write(data []byte) (int, error) {
	if this.code == 0 {
		this.code = http.StatusOK
	}
	return this.ResponseWriter.Write(data)
}
933440
func (r *Response) WriteHeader(httpStatus int) {
	r.statusCode = httpStatus
	r.ResponseWriter.WriteHeader(httpStatus)
}
1219909
func (h *Handler) WriteHeader(s int) {
	h.ResponseWriter.WriteHeader(s)
	h.responseData.status = s
}
704332
func (m *meta) write(p *page) {
	if m.root.root >= m.pgid {
		panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid))
	} else if m.freelist >= m.pgid {
		panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid))
	}

	// Page id is either going to be 0 or 1 which we can determine by the transaction ID.
	p.id = pgid(m.txid % 2)
	p.flags |= metaPageFlag

	// Calculate the checksum.
	m.checksum = m.sum64()

	m.copy(p.meta())
}
1185940
func (r *Response) WriteJson(value interface{}, contentType string) error {
	return writeJSON(r, http.StatusOK, contentType, value)
}
1222186
func WriteSiteNotFound(w http.ResponseWriter, r *http.Request) {
	status := http.StatusNotFound
	if r.ProtoMajor >= 2 {
		// TODO: use http.StatusMisdirectedRequest when it gets defined
		status = httpStatusMisdirectedRequest
	}
	WriteTextResponse(w, status, fmt.Sprintf("%d Site %s is not served on this interface\n", status, r.Host))
}
49902
func (this *statusResponseWriter) WriteHeader(code int) {
	this.code = code
	this.ResponseWriter.WriteHeader(code)
}
20339
func Write(w io.Writer, c *Compound) (err error) {
	if _, err = TagCompound.WriteTo(w); err != nil {
		return
	}

	nameTag := &String{c.Name}
	_, err = nameTag.WriteTo(w)
	if err != nil {
		return
	}

	_, err = c.WriteTo(w)
	if err != nil {
		return
	}

	return
}
994442
func (loc *Location) Write(data []byte, linkCount int) {

	loc.opts.adp.Write(loc, data)
	if !loc.IsVerbose() {
		return
	}

	output := loc.Summary(linkCount)
	if output != "" {
		println(output)
	}
}
873120
func (g *gzipWriter) WriteHeader(code int) {
	g.Header().Del("Content-Length")
	g.ResponseWriter.WriteHeader(code)
}
944498
func (f *JSONFormatter) Write(w http.ResponseWriter, v interface{}, status int) error {
	w.Header().Set(httputil.HeaderContentType, httputil.TypeApplicationJSON)
	w.WriteHeader(status)

	if v == nil {
		return nil
	}

	encoder := json.NewEncoder(w)
	return encoder.Encode(v)
}
605734
func (ini *INI) Write(w io.Writer) error {
    buf := bufio.NewWriter(w)

    //write the default section first
    if kv, ok := ini.GetKvmap(DefaultSection); ok {
        ini.write(kv, buf)
    }

    for section, kv := range ini.sections {
        if section == DefaultSection {
            continue
        }
        buf.WriteString("[" + section + "]" + ini.lineSep)
        ini.write(kv, buf)
    }
    return buf.Flush()
}
274578
func (h *NegotiationHandler) Write(w http.ResponseWriter, r *http.Request, e interface{}) {
	switch httputil.NegotiateContentType(r, []string{}, "application/json") {
	case "text/html":
		h.html.Write(w, r, e)
		return
	case "text/plain":
		h.plain.Write(w, r, e)
		return
	case "application/json":
		h.json.Write(w, r, e)
		return
	default:
		h.json.Write(w, r, e)
		return
	}
}
1206288
func (cd service) Write(thing interface{}, transId string) error {
	c := thing.(content)

	// Letting through only articles (which have body), live blogs, content packages, graphics, videos and audios (which don't have a body)
	if c.Body == "" && !contentTypesWithNoBody[c.Type] {
		logger.WithField(tid.TransactionIDKey, transId).
			Infof("There is no body with this content item therefore assuming is it not an Article: %v", c.UUID)
		return nil
	}

	params := map[string]interface{}{
		"uuid": c.UUID,
	}

	if c.Title != "" {
		params["title"] = c.Title
		params["prefLabel"] = c.Title
	}

	if c.PublishedDate != "" {
		params["publishedDate"] = c.PublishedDate
		datetimeEpoch, err := time.Parse(time.RFC3339, c.PublishedDate)

		if err != nil {
			return err
		}

		params["publishedDateEpoch"] = datetimeEpoch.Unix()
	}

	deleteEntityRelationshipsQuery := &neoism.CypherQuery{
		Statement: `MATCH (t:Thing {uuid:{uuid}})
				OPTIONAL MATCH (c:Thing)-[rel1:IS_CURATED_FOR]->(t)
				OPTIONAL MATCH (cp:Thing)<-[rel2:CONTAINS]-(t)
				DELETE rel1, rel2`,
		Parameters: map[string]interface{}{
			"uuid": c.UUID,
		},
	}

	queries := []*neoism.CypherQuery{deleteEntityRelationshipsQuery}

	labels := `:Content`

	if c.StoryPackage != "" {
		logger.WithField(tid.TransactionIDKey, transId).
			Infof("There is a story package with uuid=%v attached to Article with uuid=%v", c.StoryPackage, c.UUID)
		addStoryPackageRelationQuery := addStoryPackageRelationQuery(c.UUID, c.StoryPackage)
		queries = append(queries, addStoryPackageRelationQuery)
	}

	if c.ContentPackage != "" {
		logger.WithField(tid.TransactionIDKey, transId).
			Infof("There is a content package with uuid=%v attached to Article with uuid=%v", c.ContentPackage, c.UUID)
		addContentPackageRelationQuery := addContentPackageRelationQuery(c.UUID, c.ContentPackage)
		queries = append(queries, addContentPackageRelationQuery)
		labels = labels + `:ContentPackage`
	}

	statement := `MERGE (n:Thing {uuid: {uuid}})
		      set n={allprops}
		      set n ` + labels

	writeContentQuery := &neoism.CypherQuery{
		Statement: statement,
		Parameters: map[string]interface{}{
			"uuid":     c.UUID,
			"allprops": params,
		},
	}

	queries = append(queries, writeContentQuery)
	err := cd.conn.CypherBatch(queries)
	if err != nil {
		logger.WithMonitoringEvent("SaveNeo4j", transId, c.Type).WithField("uuid", c.UUID).WithError(err).Errorf("error: the query could not be executed")
	} else {
		logger.WithMonitoringEvent("SaveNeo4j", transId, c.Type).WithField("uuid", c.UUID).Info("the query was successfully executed")
	}
	return err
}