MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / MatchResponse

Method MatchResponse

internal/waf/waf.go:313–356  ·  view source on GitHub ↗
(req requests.Request, rawResp *http.Response, writer http.ResponseWriter)

Source from the content-addressed store, hash-verified

311}
312
313func (this *WAF) MatchResponse(req requests.Request, rawResp *http.Response, writer http.ResponseWriter) (result MatchResult, err error) {
314 if !this.hasOutboundRules {
315 return MatchResult{
316 GoNext: true,
317 }, nil
318 }
319 var hasRequestBody bool
320 var resp = requests.NewResponse(rawResp)
321 for _, group := range this.Outbound {
322 if !group.IsOn {
323 continue
324 }
325 b, hasCheckedRequestBody, set, matchErr := group.MatchResponse(req, resp)
326 if hasCheckedRequestBody {
327 hasRequestBody = true
328 }
329 if matchErr != nil {
330 return MatchResult{
331 GoNext: true,
332 HasRequestBody: hasRequestBody,
333 }, matchErr
334 }
335 if b {
336 var performResult = set.PerformActions(this, group, req, writer)
337 if !performResult.GoNextSet {
338 if performResult.GoNextGroup {
339 continue
340 }
341 return MatchResult{
342 GoNext: performResult.ContinueRequest,
343 HasRequestBody: hasRequestBody,
344 Group: group,
345 Set: set,
346 IsAllowed: performResult.IsAllowed,
347 AllowScope: performResult.AllowScope,
348 }, nil
349 }
350 }
351 }
352 return MatchResult{
353 GoNext: true,
354 HasRequestBody: hasRequestBody,
355 }, nil
356}
357
358// Save to file path
359func (this *WAF) Save(path string) error {

Callers 4

PrepareCacheMethod · 0.45
PrepareWebPMethod · 0.45
PrepareCompressionMethod · 0.45
checkWAFResponseMethod · 0.45

Calls 2

NewResponseFunction · 0.92
PerformActionsMethod · 0.80

Tested by

no test coverage detected