func (c ContentType) Execute(t *Test) error {
	if t.Response.Response == nil || t.Response.Response.Header == nil {
		return fmt.Errorf("No proper response available")
	}
	ct := t.Response.Response.Header["Content-Type"]
	if len(ct) == 0 {
		return fmt.Errorf("No Content-Type header received")
	}
	if len(ct) > 1 {
		return fmt.Errorf("Received %d Content-Type headers", len(ct))
	}
	parts := strings.Split(ct[0], ";")
	got := strings.TrimSpace(parts[0])
	want := c.Is
	if !strings.Contains(want, "/") {
		want = "/" + want
	}
	if !strings.HasSuffix(got, want) {
		return fmt.Errorf("Content-Type is %s", ct[0])
	}
	if c.Charset != "" {
		if len(parts) < 2 {
			return fmt.Errorf("No charset in %s", ct[0])
		}
		got := strings.TrimSpace(parts[1])
		want := "charset=" + c.Charset
		if got != want {
			return fmt.Errorf("Bad charset in %s", ct[0])
		}
	}
	return nil
}
Execute implements Check's Execute method.
package ht
import (
	"errors"
	"fmt"
	"net/http"
	"strings"
	"github.com/vdobler/ht/errorlist"
)
func init() {
	RegisterCheck(&Header{})
	RegisterCheck(&ContentType{})
	RegisterCheck(&FinalURL{})
	RegisterCheck(&Redirect{})
	RegisterCheck(&RedirectChain{})
}
type Header struct {
	Header string
	Condition `json:",omitempty"`
	Absent bool `json:",omitempty"`
}
func (h Header) Execute(t *Test) error {
	key := http.CanonicalHeaderKey(h.Header)
	values := t.Response.Response.Header[key]
	if len(values) == 0 && h.Absent {
		return nil
	} else if len(values) == 0 && !h.Absent {
		return fmt.Errorf("Header %s not received", h.Header)
	} else if len(values) > 0 && h.Absent {
		return fmt.Errorf("Forbidden header %s received", h.Header)
	}
	return h.Fulfilled(values[0])
}
func (h *Header) Prepare(*Test) error {
	return h.Condition.Compile()
}
var _ Preparable = &Header{}
type ContentType struct {
	Is string
	Charset string `json:",omitempty"`
}