zeek/policy/protocols/http/base/utils.bro
Jon Siwek 78e2d768c7 Adding a documentation coverage test.
- The CMake targets for generating reST docs from policy scripts are now
  automatically generated via the genDocSourcesList.sh script

- Fixed a lot of parsing errors in policy scripts that I saw along the way
2011-07-23 20:55:06 -05:00

40 lines
934 B
Text

##! Utilities specific for HTTP processing.
@load ./main
module HTTP;
export {
global extract_keys: function(data: string, kv_splitter: pattern): string_vec;
global build_url: function(h: Info): string;
global build_url_http: function(h: Info): 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], /=/);
if ( 1 in key_val )
key_vec[|key_vec|] = key_val[1];
}
return key_vec;
}
function build_url(h: Info): string
{
local uri = h?$uri ? h$uri : "/<missed_request>";
local host = h?$host ? h$host : fmt("%s", h$id$resp_h);
if ( h$id$resp_p != 80/tcp )
host = fmt("%s:%s", host, h$id$resp_p);
return fmt("%s%s", host, uri);
}
function build_url_http(h: Info): string
{
return fmt("http://%s", build_url(h));
}