mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-05-06 14:03:40 +08:00
fix: add WebDAV methods (PROPFIND, PROPPATCH, MKCOL, etc.) to ValidHTTPMethods
The structured access logs were showing an empty method field for PROPFIND requests because the parser only recognized standard HTTP methods. Changes: - Add WebDAV methods (RFC 4918) to ValidHTTPMethods in parser/types.go: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK - Update the validMethods check in indexer/parallel_indexer_optimized.go - Add test cases for WebDAV methods in parser_test.go Fixes: PROPFIND method not showing in structured access logs Co-authored-by: Jacky <me@jackyu.cn>
This commit is contained in:
@@ -289,8 +289,12 @@ func isValidLogEntry(doc *LogDocument) bool {
|
||||
// Check HTTP method if present
|
||||
if doc.Method != "" {
|
||||
validMethods := map[string]bool{
|
||||
// Standard HTTP methods
|
||||
"GET": true, "POST": true, "PUT": true, "DELETE": true,
|
||||
"HEAD": true, "OPTIONS": true, "PATCH": true, "CONNECT": true, "TRACE": true,
|
||||
// WebDAV methods (RFC 4918)
|
||||
"PROPFIND": true, "PROPPATCH": true, "MKCOL": true,
|
||||
"COPY": true, "MOVE": true, "LOCK": true, "UNLOCK": true,
|
||||
}
|
||||
if !validMethods[doc.Method] {
|
||||
return false
|
||||
|
||||
@@ -80,6 +80,37 @@ func TestParser_ParseLine(t *testing.T) {
|
||||
entry.BytesSent == 0
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "WebDAV PROPFIND method",
|
||||
line: `192.168.1.100 - - [25/Dec/2023:10:00:00 +0000] "PROPFIND /webdav/ HTTP/1.1" 207 1234 "-" "davfs2/1.5.4"`,
|
||||
validate: func(entry *AccessLogEntry) bool {
|
||||
return entry.IP == "192.168.1.100" &&
|
||||
entry.Method == "PROPFIND" &&
|
||||
entry.Path == "/webdav/" &&
|
||||
entry.Status == 207 &&
|
||||
entry.BytesSent == 1234
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "WebDAV MKCOL method",
|
||||
line: `10.0.0.5 - - [25/Dec/2023:10:00:00 +0000] "MKCOL /webdav/newdir/ HTTP/1.1" 201 0 "-" "WebDAVClient/1.0"`,
|
||||
validate: func(entry *AccessLogEntry) bool {
|
||||
return entry.IP == "10.0.0.5" &&
|
||||
entry.Method == "MKCOL" &&
|
||||
entry.Path == "/webdav/newdir/" &&
|
||||
entry.Status == 201
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "WebDAV LOCK method",
|
||||
line: `172.16.0.1 - - [25/Dec/2023:10:00:00 +0000] "LOCK /webdav/file.txt HTTP/1.1" 200 512 "-" "Microsoft-WebDAV"`,
|
||||
validate: func(entry *AccessLogEntry) bool {
|
||||
return entry.IP == "172.16.0.1" &&
|
||||
entry.Method == "LOCK" &&
|
||||
entry.Path == "/webdav/file.txt" &&
|
||||
entry.Status == 200
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
config := DefaultParserConfig()
|
||||
|
||||
@@ -100,8 +100,9 @@ func DefaultParserConfig() *Config {
|
||||
}
|
||||
}
|
||||
|
||||
// ValidHTTPMethods Valid HTTP methods
|
||||
// ValidHTTPMethods Valid HTTP methods including WebDAV methods
|
||||
var ValidHTTPMethods = map[string]bool{
|
||||
// Standard HTTP methods
|
||||
"GET": true,
|
||||
"POST": true,
|
||||
"PUT": true,
|
||||
@@ -111,6 +112,14 @@ var ValidHTTPMethods = map[string]bool{
|
||||
"PATCH": true,
|
||||
"TRACE": true,
|
||||
"CONNECT": true,
|
||||
// WebDAV methods (RFC 4918)
|
||||
"PROPFIND": true,
|
||||
"PROPPATCH": true,
|
||||
"MKCOL": true,
|
||||
"COPY": true,
|
||||
"MOVE": true,
|
||||
"LOCK": true,
|
||||
"UNLOCK": true,
|
||||
}
|
||||
|
||||
// Parser errors (moved to errors.go as Cosy Errors)
|
||||
|
||||
Reference in New Issue
Block a user