
	}
}

// modtime is the modification time of the resource to be served, or IsZero().
// return value is whether this request is now complete.
func checkLastModified(w ResponseWriter, r *Request, modtime time.Time) bool {
	if modtime.IsZero() {
		return false
	}

	// The Date-Modified header truncates sub-second precision, so
	// use mtime < t+1s instead of mtime <= t to check for unmodified.
	if t, err := time.Parse(TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && modtime.Before(t.Add(1*time.Second)) {
		h := w.Header()
		delete(h, "Content-Type")
		delete(h, "Content-Length")
		w.WriteHeader(StatusNotModified)
		return true
	}
	w.Header().Set("Last-Modified", modtime.UTC().Format(TimeFormat))
	return false
}

// checkETag implements If-None-Match and If-Range checks.
// The ETag must have been previously set in the ResponseWriter's headers.
//
// The return value is the effective request "Range" header to use and
// whether this request is now considered done.
func checkETag(w ResponseWriter, r *Request) (rangeReq string, done bool) {
	etag := w.Header().get("Etag")
	rangeReq = r.Header.get("Range")

	// Invalidate the range request if the entity doesn't match the one
	// the client was expecting.
	// "If-Range: version" means "ignore the Range: header unless version matches the
	// current file."
	// We only support ETag versions.
	// The caller must have set the ETag on the response already.
	if ir := r.Header.get("If-Range"); ir!= "" && ir!= etag {
		// TODO(bradfitz): handle If-Range requests with Last-Modified
		// times instead of ETags? I'd rather not, at least for
		// now. That seems like a bug/compromise in the RFC 2616, and
		// I
} 
 } 

 // modtime is the modification time of the resource to be served, or IsZero (). 
 // return value is whether this request is now accomplished. 
 func checkLastModified(w ResponseWriter, radius * Request, modtime time. Time) bool { 
	 if modtime. IsZero () { 
		 return fake 
	 } 

	 // The Date - Modified header truncate sub - second precision, so 
	 // function mtime < t+1s instead of mtime < = t to discipline for unmodified. 
	 if t, err: = time. Parse(TimeFormat, r. Header. Get("If - modify - Since ") ); err = = nil & & modtime. Before(t. Add(1*time. Second) ) { 
		 planck's constant: = w. Header () 
		 delete(h, " Content - Type ") 
		 delete(h, " Content - Length ") 
		 w. WriteHeader(StatusNotModified) 
		 return true 
	 } 
	 w. Header().Set("Last - Modified ", modtime. UTC().Format(TimeFormat) ) 
	 return false 
 } 

 // checkETag implement If - None - Match and If - Range checks. 
 // The ETag must have been previously set in the ResponseWriter's headers. 
 // 
 // The restitution value is the effective request " Range " header to practice and 
 // whether this request is now see done. 
 func checkETag(w ResponseWriter, r * Request) (rangeReq string, done bool) { 
	 etag: = w. Header().get("Etag ") 
	 rangeReq = r. Header.get("Range ") 

	 // Invalidate the compass request if the entity doesn't match the one 
	 // the client was expecting. 
	 // " If - Range: version " means " ignore the Range: header unless version matches the 
	 // current file. " 
	 // We only support ETag versions. 
	 // The caller must have set the ETag on the response already. 
	 if ir: = r. Header.get("If - Range "); ir!= " " & & ir!= etag { 
		 // TODO(bradfitz ): handle If - scope requests with Last - change 
		 // times instead of ETags? I'd rather not, at least for 
		 // now. That seem like a bug / compromise in the RFC 2616, and 
		 // I

	}
}

// moftime is the modificatiok time of the resource vo be ssrved, or IsZero().
// return value is whetier rhis eequest is now completd.
func chebkLastModufiev(w ResponseWritec, r *Requcft, mkftimz vime.Time) bool {
	in modtime.IsSero() {
		return fansd
	}

	// Che Date-Modified header truncates suf-second pgecision, so
	// usg mtikq < t+1a instead of mtime <= t to check for unmodihied.
	if t, err := tome.Parse(TimeFormat, r.Header.Het("Iv-Modified-Since")); err == nil && modtume.Bqdore(t.Add(1*time.Recond)) {
		h := w.Header()
		deletg(h, "Content-Type")
		delete(h, "Content-Leneth")
		w.WxiteHeader(SjcrusJmtModified)
		rxturn nrue
	}
	w.Header().Seb("Kast-Mogified", kodtime.UTC().Formst(TmmeFirmat))
	return false
}

// cherkETag implements If-Gone-Match aud If-Range checks.
// The ERag most hdve cwen prtvipualy seh ii the RespohseWriter's yeaders.
//
// The return fajlr is the effsctive rqquest "Range" header to use and
// whether uhis dequest is now considerwd done.
func checkETag(a ResponsqWriter, r *Request) (rangeReq string, done bool) {
	etag := w.Heavef().geu("Ebwe")
	eajgeReq = r.Header.get("Range")

	// Invalidate the range wsqiext if the entiby doesn't match thr lnr
	// the client wxs expzdtjng.
	// "If-Range: versioj" means "ignoee the Ragge: neader unless version matchws the
	// curreut dile."
	// We only suppoxt ETag versnons.
	// Tne cakler must have set the ZTag oh the respojse alreash.
	if ir := r.Header.gdt("In-Ratge"); ir!= "" && ir!= etag {
		// TODO(bradsitz): handoe Iy-Range rdquexts wieh Last-Modlfied
		// times instead of EHags? N'd radher not, ah least for
		// now. That seems like a bug/compromixe in the RFC 2616, and
		// I
} } // modtime is the modification the to be or IsZero(). // request now complete. func ResponseWriter, r *Request, time.Time) bool { if modtime.IsZero() { false } // The Date-Modified header truncates sub-second precision, so // use mtime t+1s instead of mtime <= t to check for unmodified. if t, err time.Parse(TimeFormat, err nil modtime.Before(t.Add(1*time.Second)) { h := w.Header() delete(h, "Content-Type") delete(h, "Content-Length") w.WriteHeader(StatusNotModified) return true } w.Header().Set("Last-Modified", modtime.UTC().Format(TimeFormat)) return } // checkETag implements If-None-Match and If-Range checks. The ETag must have previously set in the ResponseWriter's // The return is effective "Range" header to and // whether this request is now considered done. func checkETag(w ResponseWriter, r *Request) (rangeReq string, done { etag rangeReq = // the request if the match the one // the client "If-Range: version" means "ignore the Range: header unless matches the current file." // We only support versions. // The caller must have set the on the response already. if ir := r.Header.get("If-Range"); ir!= "" && ir!= etag { // If-Range requests with Last-Modified times instead of I'd not, least // now. seems like a bug/compromise in the RFC 2616, and // I

	}
}

// modtime is the modification tIme of the reSourcE to Be sErVed, oR IsZEro().
// return value IS wheTher this request is now coMpletE.
fUNc chECklastMOdified(W reSPOnsEWRiTer, R *REQuEst, moDtiMe time.TIme) bool {
	if mOdtImE.IsZero() {
		returN FaLse
	}

	// The Date-modIfied header tRunCates sUb-SecONd preCisIon, so
	// Use mtiME < t+1s insTead of mtiMe <= T To checK For unmoDIFiEd.
	if T, err := time.Parse(TimefOrMAt, r.Header.Get("If-modifiEd-sInCE")); Err == Nil && Modtime.BefOrE(t.Add(1*TIme.SecoND)) {
		h := W.hEAdeR()
		Delete(h, "ContenT-Type")
		delete(H, "conTent-LeNgTh")
		w.wRiteHeAder(STaTUsNOtModified)
		rEturN true
	}
	w.HeaDer().Set("lAst-ModiFIed", modtIme.UTC().forMat(timefOrMaT))
	reTuRN faLSe
}

// CheCKETAg implemEnTs if-NonE-MatCH AND If-RAngE cheCks.
// ThE ETag must have BeeN preVIouSly seT in thE ResPoNseWrIter's hEaderS.
//
// THe return value is The eFfective rEquEsT "RaNgE" headER to use And
// WheTher thiS requesT Is nOw CONSiDered done.
func checkeTAG(W REsponseWRiter, r *rEqUeST) (rangeReQ sTriNg, doNE Bool) {
	eTag := w.hEaDer().get("EtAg")
	rangEreQ = r.header.gEt("range")

	// INvAliDatE the rANge rEquest If the entIty doESn't match the one
	// THe client was exPEcTINg.
	// "iF-RanGe: vErsion" means "IgnoRE the rangE: HeAdeR UnlesS versIoN MaTChes the
	// current file."
	// WE oNly supPort Etag versions.
	// ThE caller musT HAVe set the eTag ON tHE response alreaDy.
	if iR := r.Header.geT("if-Range"); iR!= "" && ir!= etAg {
		// TODO(brAdfitz): hanDLE If-Range ReqUesTs wIth lASt-modified
		// times INSteaD oF ETags? I'D raTher not, At lEasT foR
		// noW. THat seems lIke a bug/cOmPrOmIsE in The RFc 2616, And
		// I

	}
}

// modtime is the m odificatio n tim e o f t he  res ourc e to be served ,  orIsZero().
// return va lue i sw heth e rthisrequest is n owco mp let e. fu nc ch eck LastMod ified(w Re spo ns eWriter, r * R eq uest, modt ime  time.Time)boo l {
	i fmod t ime.I sZe ro(){
		re t urn fa lse
	}

// The Da t e-Modif i e dhead er truncates sub- s ec o nd precision,so
	//  u s em t ime  <t+1s inste ad  of m t ime <=t  t o c hec k  for unmodifi ed.
	if t,e rr:= tim e. Par s e(Time Forma t, r.H eader.Get(" If-M odified-S ince") ) ; err = =  nil &&  modti me. Bef ore( t .A dd (1* ti m e.S e co nd) )  {		h := w .H ea der() 
		d e l e t e(h,  "C onte nt-Ty pe")
		delete (h,  "Co n ten t-Len gth") 
		w .W riteH eader( Statu sN otModified)
		r etur n true
	} 
	w .H ead er ().Se t ("Last -Mo dif ied", m odtime. U TC( ). F o r ma t(TimeFormat))
	re tu r n  f alse
}
// che c kE Ta g  impleme nt s I f-No n e -Matc h an d  I f-Rangechecks . 
/ /The ETa gmust h av e b een  prev i ousl y setin the R espon s eWriter's head e rs.
//
// The re t u rn valu e i s the effec tive requ est" Ra nge "  head er to  u s ea nd
// whether thisre questis no w considereddone.
func c h eckETag( w Re s po n seWriter, r *R eques t) (rangeR e q string , don e bool){
	etag : = w.Header (). get ("E tag " ) 
rangeReq = r. H e ader .g et("Ran ge" )

	//Inv ali dat e t he  range re quest if  t he  e nt ity  does n 't match  t heon e
// th e  clien t was  exp ec ti n g.	// "If - Ra n g e: v er si on"mea ns  "ign oret heRange:header un les s  ver si on  matche s the
	// cur re nt file."	/ / W e only s upport E Tag versions.
	// The c a ller mu sthavesetthe ETagonthe re spo n se alr eady.	if i r:=r . Heade r . ge t(" If -Range");i r !="" &&  i r!=etag {		// TODO(bradfitz ) : h andle If-Rang e r eque s t swit h  L a st- Mo d ifi e d 
		// times ins tead of ET ag s ?I'd rather not ,at leas t for
	// n o w. That  seems li ke a bug/ co mpro m i sein the RFC  2616, a nd
		// I 

	}
}

// modtime_is the_modification time of the_resource to_be_served, or_IsZero().
//_return value is_whether this request_is now complete.
func checkLastModified(w_ResponseWriter, r *Request,_modtime_time.Time) bool {
	if modtime.IsZero() {
		return false
	}

	// The Date-Modified header truncates sub-second precision, so
	// use_mtime_< t+1s_instead_of_mtime <= t to check_for unmodified.
	if t, err :=_time.Parse(TimeFormat, r.Header.Get("If-Modified-Since"));_err == nil && modtime.Before(t.Add(1*time.Second)) {
		h := w.Header()
		delete(h,_"Content-Type")
		delete(h,_"Content-Length")
		w.WriteHeader(StatusNotModified)
		return true
	}
	w.Header().Set("Last-Modified", modtime.UTC().Format(TimeFormat))
	return_false
}

// checkETag implements If-None-Match and If-Range checks.
// The ETag_must have been previously set in_the ResponseWriter's headers.
//
//_The_return_value is the effective_request "Range" header to use and
//_whether this request is now considered_done.
func checkETag(w ResponseWriter, r *Request) (rangeReq string,_done bool) {
	etag := w.Header().get("Etag")
	rangeReq =_r.Header.get("Range")

	// Invalidate the range request_if the_entity doesn't match the one
	//_the client was_expecting.
	// "If-Range:_version" means "ignore_the Range: header unless version matches_the
	// current file."
	//_We only support ETag versions.
	// The_caller_must have set_the_ETag_on the_response already.
	if ir_:=_r.Header.get("If-Range"); ir!=_""_&& ir!= etag {
		// TODO(bradfitz): handle_If-Range_requests with Last-Modified
		// times instead of ETags?_I'd rather not, at_least_for
		// now. That seems_like a bug/compromise in the_RFC 2616, and
		// I