Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/cmd/dist/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,20 @@ func findgoversion() string {

// isGitRepo reports whether the working directory is inside a Git repository.
func isGitRepo() bool {
// NB: simply checking the exit code of `git rev-parse --git-dir` would
// suffice here, but that requires deviating from the infrastructure
// provided by `run`.
gitDir := chomp(run(goroot, 0, "git", "rev-parse", "--git-dir"))
if !filepath.IsAbs(gitDir) {
gitDir = filepath.Join(goroot, gitDir)
}
fi, err := os.Stat(gitDir)
return err == nil && fi.IsDir()
p := ".git"
for {
fi, err := os.Stat(p)

if os.IsNotExist(err) {
p = filepath.Join("..", p)
continue
}

if err != nil || !fi.IsDir() {
return false
}
return true
}
}

/*
Expand Down
50 changes: 50 additions & 0 deletions src/net/http/httputil/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,31 @@ type ReverseProxy struct {
// If nil, logging goes to os.Stderr via the log package's
// standard logger.
ErrorLog *log.Logger

// ModifyResponse is an optional function that modifies the
// Response from the backend. It is called if the backend
// returns a response at all, with any HTTP status code.
// If the backend is unreachable, the optional ErrorHandler is
// called without any call to ModifyResponse.
//
// If ModifyResponse returns an error, ErrorHandler is called
// with its error value. If ErrorHandler is nil, its default
// implementation is used.
// This is to enhance EC Solaris SPARC64 plugin build so that it will modify the TLS response header.
ModifyResponse func(*http.Response) error

// BufferPool optionally specifies a buffer pool to
// get byte slices for use by io.CopyBuffer when
// copying HTTP response bodies.
BufferPool BufferPool

// ErrorHandler is an optional function that handles errors
// reaching the backend or errors from ModifyResponse.
//
// If nil, the default is to log the provided error and return
// a 502 Status Bad Gateway response.
// This is to support EC Solaris SPARC64 build
ErrorHandler func(http.ResponseWriter, *http.Request, error)
}

// A BufferPool is an interface for getting and returning temporary
Expand All @@ -61,6 +81,27 @@ type BufferPool interface {
Put([]byte)
}

// Add default Error Handler to support EC Solaris SPARC64 build
func (p *ReverseProxy) defaultErrorHandler(rw http.ResponseWriter, req *http.Request, err error)\
{

p.logf("http: proxy error: %v", err)

rw.WriteHeader(http.StatusBadGateway)

}


// Add Error Handler to support EC Solaris SPARC64 build
func (p *ReverseProxy) getErrorHandler() func(http.ResponseWriter, *http.Request, error) {
if p.ErrorHandler != nil {

return p.ErrorHandler
}

return p.defaultErrorHandler
}

func singleJoiningSlash(a, b string) string {
aslash := strings.HasSuffix(a, "/")
bslash := strings.HasPrefix(b, "/")
Expand Down Expand Up @@ -215,6 +256,15 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
for _, h := range hopHeaders {
res.Header.Del(h)
}

// add to support EC Solaris build
if p.ModifyResponse != nil {
if err := p.ModifyResponse(res); err != nil {
res.Body.Close()
p.getErrorHandler()(rw, outreq, err)
return
}
}

copyHeader(rw.Header(), res.Header)

Expand Down