// OverrideHeader replaces the headers of the HTTP response
179724
func (rm *responseModifier) OverrideHeader(b []byte) error {
	header := http.Header{}
	if err := json.Unmarshal(b, &header); err != nil {
		return err
	}
	rm.header = header
	return nil
}
870947
func inheritHeaders(childs, parents map[HTTPHeader]Header, dicts map[string]interface{}) map[HTTPHeader]Header {
	if len(childs) == 0 {
		childs = map[HTTPHeader]Header{}
	}

	for name, parent := range parents {
		h, ok := childs[name]
		if !ok {
			if optionalTraitProperty(string(name)) { // don't inherit optional property if not exist
				continue
			}
			h = Header{}
		}
		parent.Name = string(name)
		np := NamedParameter(h)
		np.inherit(NamedParameter(parent), dicts)
		childs[name] = Header(np)
	}
	return childs
}
103753
func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
	replacer := httpserver.NewReplacer(r, nil, "")
	rww := &responseWriterWrapper{w: w}
	for _, rule := range h.Rules {
		if httpserver.Path(r.URL.Path).Matches(rule.Path) {
			for name := range rule.Headers {

				// One can either delete a header, add multiple values to a header, or simply
				// set a header.

				if strings.HasPrefix(name, "-") {
					rww.delHeader(strings.TrimLeft(name, "-"))
				} else if strings.HasPrefix(name, "+") {
					for _, value := range rule.Headers[name] {
						rww.Header().Add(strings.TrimLeft(name, "+"), replacer.Replace(value))
					}
				} else {
					for _, value := range rule.Headers[name] {
						rww.Header().Set(name, replacer.Replace(value))
					}
				}
			}
		}
	}
	return h.Next.ServeHTTP(rww, r)
}
544410
func MethodFromHeader(header string) MethodOverrideGetter {
	return func(c echo.Context) string {
		return c.Request().Header.Get(header)
	}
}
241416
func overrideCluster(opts *Options) error {
	if opts.Cluster.ListenStr == "" {
		// This one is enough to disable clustering.
		opts.Cluster.Port = 0
		return nil
	}
	clusterURL, err := url.Parse(opts.Cluster.ListenStr)
	if err != nil {
		return err
	}
	h, p, err := net.SplitHostPort(clusterURL.Host)
	if err != nil {
		return err
	}
	opts.Cluster.Host = h
	_, err = fmt.Sscan(p, &opts.Cluster.Port)
	if err != nil {
		return err
	}

	if clusterURL.User != nil {
		pass, hasPassword := clusterURL.User.Password()
		if !hasPassword {
			return errors.New("expected cluster password to be set")
		}
		opts.Cluster.Password = pass

		user := clusterURL.User.Username()
		opts.Cluster.Username = user
	} else {
		// Since we override from flag and there is no user/pwd, make
		// sure we clear what we may have gotten from config file.
		opts.Cluster.Username = ""
		opts.Cluster.Password = ""
	}

	return nil
}
1071477
func OverrideResolve(resolveFN func(net string, addr string) (*net.TCPAddr, error)) {
	resolveTCPAddr.Store(resolveFN)
}
1318597
func (c *engineIPC) OverrideVserver(vserver *seesaw.VserverOverride) error {
	override := &ipc.Override{Ctx: c.ctx, Vserver: vserver}
	return c.client.Call("SeesawEngine.OverrideVserver", override, nil)
}
490699
func (r *RequestConfig) Header(name, value string) *RequestConfig {
	r.HeaderMap.Add(name, value)
	return r
}
252882
func RequestHeader(header string) Option {
	return func(cs *csrf) {
		cs.opts.RequestHeader = header
	}
}
1036241
func (p *WebPage) CustomHeaders() (http.Header, error) {
	var resp struct {
		Value map[string]string `json:"value"`
	}
	if err := p.ref.process.doJSON("POST", "/webpage/CustomHeaders", map[string]interface{}{"ref": p.ref.id}, &resp); err != nil {
		return nil, err
	}

	// Convert to a header object.
	hdr := make(http.Header)
	for key, value := range resp.Value {
		hdr.Set(key, value)
	}
	return hdr, nil
}
723688
func WithHostOverride(value string) options.Opt {
	return func(p options.Params) {
		if setter, ok := p.(hostOverrideSetter); ok {
			setter.SetHostOverride(value)
		}
	}
}
713903
func (dfs *DistributedFilesystem) Override(newimg, oldimg string) error {

	// make sure the old image exists
	oldImage, err := dfs.index.FindImage(oldimg)
	if err != nil {
		glog.Errorf("Could not find image %s in registry: %s", oldimg, err)
		return err
	}

	// make sure the new image exists
	newImage, err := dfs.docker.FindImage(newimg)
	if err != nil {
		glog.Errorf("Could not find replacement image %s: %s", newimg, err)
		return err
	}

	// push the image into the registry
	hash, err := dfs.docker.GetImageHash(newImage.ID)
	if err != nil {
		glog.Errorf("Could not get hash for image %s: %s", newimg, err)
		return err
	}

	if err := dfs.index.PushImage(oldImage.String(), newImage.ID, hash); err != nil {
		glog.Errorf("Could not replace image %s with %s (%s): %s", oldImage, newimg, newImage.ID, err)
		return err
	}
	return nil
}
198180
func (s *StartTaskExecutionInput) SetOverrideOptions(v *Options) *StartTaskExecutionInput {
	s.OverrideOptions = v
	return s
}
1243831
func getOverrideChain(controllerName, action string) []Filter {
	if newChain, ok := filterOverrides[action]; ok {
		return newChain
	}
	if newChain, ok := filterOverrides[controllerName]; ok {
		return newChain
	}
	return nil
}
1041354
func OverrideDial(dialFN func(ctx context.Context, net string, addr string) (net.Conn, error)) {
	dial.Store(dialFN)
}
87143
func ValueOverrides(raw []byte) InstallOption {
	return func(opts *options) {
		opts.instReq.Values = &cpb.Config{Raw: string(raw)}
	}
}
934443
func (cli *OpsGenieClient) ScheduleOverride() (*OpsGenieScheduleOverrideClient, error) {
	cli.makeHTTPTransportSettings()

	scheduleOverrideClient := new(OpsGenieScheduleOverrideClient)
	scheduleOverrideClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		scheduleOverrideClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return scheduleOverrideClient, nil
}