zeek/policy/http/utils.bro
Seth Hall e1724bf286 HTTP cleanups.
* Multiple pipelined requests before any replies is now supported.
* HTTP::build_url function that takes a connection and builds a
  url current request/response pair.
* I left in an example to show a likely bug with the record
  extension mechanism.
2011-04-08 22:38:39 -04:00

32 lines
No EOL
798 B
Text

##! Utilities specific for HTTP processing.
@load http/base
module HTTP;
export {
global extract_keys: function(data: string, kv_splitter: pattern): string_vec;
global build_url: function(c: connection): string;
}
function extract_keys(data: string, kv_splitter: pattern): string_vec
{
local key_vec: vector of string = vector("");
local parts = split(data, kv_splitter);
for ( part_index in parts )
{
local key_val = split1(parts[part_index], /=/);
# TODO: Change once problem with empty vectors is fixed. (remove the initial value)
if ( 1 in key_val )
key_vec[|key_vec|+1] = key_val[1];
}
return key_vec;
}
function build_url(c: connection): string
{
local host = c$http?$host ? c$http$host : fmt("%s",c$id$resp_h);
return fmt("http://%s/%s", host, c$http$uri);
}