예제 #1
0
파일: stygian.go 프로젝트: thraxil/stygian
// Filter out only requests with the given response status code
func StatusIs(status int) goproxy.RespCondition {
	return goproxy.RespConditionFunc(
		func(resp *http.Response, ctx *goproxy.ProxyCtx) bool {
			if resp == nil {
				return false
			}
			return resp.StatusCode == status
		})
}
예제 #2
0
파일: stygian.go 프로젝트: thraxil/stygian
// True for any text/* content type except a couple
// specific exceptions that generally indicate things
// we don't care about (css/js/json)
func TextButNotCode() goproxy.RespCondition {
	return goproxy.RespConditionFunc(
		func(resp *http.Response, ctx *goproxy.ProxyCtx) bool {
			contentType := resp.Header.Get("Content-Type")
			if !strings.HasPrefix(contentType, "text/") {
				return false
			}
			r := strings.HasPrefix(contentType, "text/css") ||
				strings.HasPrefix(contentType, "text/javascript") ||
				strings.HasPrefix(contentType, "text/json")
			return !r
		})
}