func (rs RequestSanitizer) Sanitize(r *http.Request) *http.Request {
	if r == nil {
		return nil
	}

	copy := r.Clone(r.Context())
	for header, values := range copy.Header {
		if rs.IsHeaderDisallowed(header) {
			copy.Header[header] = rs.KeyValuesSanitizer.SanitizeKeyValues(header, values...)
		}
	}
	if copy.URL != nil {
		queryParams := copy.URL.Query()
		for queryParam, values := range queryParams {
			if rs.IsQueryParamDisallowed(queryParam) {
				queryParams[queryParam] = rs.KeyValuesSanitizer.SanitizeKeyValues(queryParam, values...)
			}
		}
		copy.URL.RawQuery = queryParams.Encode()

		// also sanitize the path
		copy.URL.Path = rs.PathSanitizer.SanitizePath(copy.URL.Path)
	}
	return copy
}
// Sanitize applies sanitization options to a given request.
Sanitize applies sanitization options to a given request.
// Sanitize applies sanitization options to a given request .
func (rs RequestSanitizer) Sanitize(r *http.Request) *http.Request {
	if r == nil {
		return nil
	}
	copy := r.Clone(r.Context())
	for header, values := range copy.Header {
		if rs.IsHeaderDisallowed(header) {
			copy.Header[header] = rs.KeyValuesSanitizer.SanitizeKeyValues(header, values...)
		}
	}
	if copy.URL != nil {
		queryParams := copy.URL.Query()
		for queryParam, values := range queryParams {
			if rs.IsQueryParamDisallowed(queryParam) {
				queryParams[queryParam] = rs.KeyValuesSanitizer.SanitizeKeyValues(queryParam, values...)
			}
		}
		copy.URL.RawQuery = queryParams.Encode()
		copy.URL.Path = rs.PathSanitizer.SanitizePath(copy.URL.Path)
	}
	return copy
}
func ( rs RequestSanitizer ) Sanitize ( r * http . Request ) * http . Request { if r == nil { return nil } copy := r . Clone ( r . Context ( ) ) for header , values := range copy . Header { if rs . IsHeaderDisallowed ( header ) { copy . Header [ header ] = rs . KeyValuesSanitizer . SanitizeKeyValues ( header , values ... ) } } if copy . URL != nil { queryParams := copy . URL . Query ( ) for queryParam , values := range queryParams { if rs . IsQueryParamDisallowed ( queryParam ) { queryParams [ queryParam ] = rs . KeyValuesSanitizer . SanitizeKeyValues ( queryParam , values ... ) } } copy . URL . RawQuery = queryParams . Encode ( ) copy . URL . Path = rs . PathSanitizer . SanitizePath ( copy . URL . Path ) } return copy }
Sanitize applies sanitization options to a given request.
Sanitize applies sanitization options to a given request .
// also sanitize the path