@@ -1845,6 +1845,57 @@ func TestHttpParser_hostHeader(t *testing.T) {
18451845 }
18461846}
18471847
1848+ func TestHttpParser_Extension (t * testing.T ) {
1849+ template := "HEAD %s HTTP/1.1\r \n " +
1850+ "Host: abc.com\r \n " +
1851+ "\r \n "
1852+ var store eventStore
1853+ http := httpModForTests (& store )
1854+ for _ , test := range []struct {
1855+ title , path string
1856+ expected common.MapStr
1857+ }{
1858+ {
1859+ title : "Zip Extension" ,
1860+ path : "/files.zip" ,
1861+ expected : common.MapStr {
1862+ "url.full" : "http://abc.com/files.zip" ,
1863+ "url.extension" : "zip" ,
1864+ },
1865+ },
1866+ {
1867+ title : "No Extension" ,
1868+ path : "/files" ,
1869+ expected : common.MapStr {
1870+ "url.full" : "http://abc.com/files" ,
1871+ "url.extension" : nil ,
1872+ },
1873+ },
1874+ } {
1875+ t .Run (test .title , func (t * testing.T ) {
1876+ request := fmt .Sprintf (template , test .path )
1877+ tcptuple := testCreateTCPTuple ()
1878+ packet := protos.Packet {Payload : []byte (request )}
1879+ private := protos .ProtocolData (& httpConnectionData {})
1880+ private = http .Parse (& packet , tcptuple , 1 , private )
1881+ http .Expired (tcptuple , private )
1882+ trans := expectTransaction (t , & store )
1883+ if ! assert .NotNil (t , trans ) {
1884+ t .Fatal ("nil transaction" )
1885+ }
1886+ for field , expected := range test .expected {
1887+ actual , err := trans .GetValue (field )
1888+ assert .Equal (t , expected , actual , field )
1889+ if expected != nil {
1890+ assert .Nil (t , err , field )
1891+ } else {
1892+ assert .Equal (t , common .ErrKeyNotFound , err , field )
1893+ }
1894+ }
1895+ })
1896+ }
1897+ }
1898+
18481899func benchmarkHTTPMessage (b * testing.B , data []byte ) {
18491900 http := httpModForTests (nil )
18501901 parser := newParser (& http .parserConfig )
0 commit comments