Skip to content
Snippets Groups Projects
Select Git revision
  • 135532a3d04615c25f70cf941676acbf61d581a0
  • noblogs default
  • noblogs-5.7.1
  • upstream
  • noblogs-5.7
  • noblogs-5.6new
  • upstream5.5.1
  • noblogs28dic
  • upstream28dic
  • noblogs-5.5.1
  • noblogs-5.4.2
  • noblogs-5.4_seconda
  • noblogs-5.4
  • noblogs-7c
  • wp5.2.3p3
  • mergedbconf
  • noblogs-5.7.1
  • noblogs.5.7.0p1
  • noblogs-5.7.0
  • noblogs-5.6p3
  • noblogs5.6p2
  • noblogs-5.6p1
  • noblogs-5.6
  • noblogs-5.4.2p1
  • noblogs-5.4.2
  • noblogs-5.4.1
  • noblogs-5.4
  • noblogs-p5.4
  • noblogs-5.3.2p2
  • noblogs-5.3.2p1
  • noblogs-5.3.2
  • noblogs-5.3
  • noblogs-5.2.3p4
  • noblogs-5.2.3p3
  • noblogs-5.2.3p2
  • noblogs-5.2.3p1
36 results

class-wp-fatal-error-handler.php

Blame
  • static.go 788 B
    package httputil
    
    import (
    	"bytes"
    	"io/ioutil"
    	"net/http"
    	"os"
    	"time"
    )
    
    // StaticContent is an http.Handler that serves in-memory data as if
    // it were a static file.
    type StaticContent struct {
    	modtime time.Time
    	name    string
    	data    []byte
    }
    
    // LoadStaticContent creates a StaticContent by loading data from a file.
    func LoadStaticContent(path string) (*StaticContent, error) {
    	stat, err := os.Stat(path)
    	if err != nil {
    		return nil, err
    	}
    	data, err := ioutil.ReadFile(path) // #nosec
    	if err != nil {
    		return nil, err
    	}
    	return &StaticContent{
    		name:    path,
    		modtime: stat.ModTime(),
    		data:    data,
    	}, nil
    }
    
    func (c *StaticContent) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    	http.ServeContent(w, req, c.name, c.modtime, bytes.NewReader(c.data))
    }