<commit_before>$use_global_replace_vars = "true"
#       !!! WARNING THIS FILE IS GENERATED AND PROJECT SPECIFIC !!!
#
# Transform the request from a downstream client so it is ready to issue to the
# upstream host. This script exports variables relevent to processing the
# request. These files are generated and project specific.
#
# Inputs:
#  * The raw http request header (without the \r\n\r\n separator)
#  * This script listens to the X-Moov-Secure header to determine if the request
#    should be issued via SSL.
#  * Optionally the accept_encoding variable can be specified to set the
#    supported compression methods such as "gzip,deflate"
#  * This script does not currently require any enviroment variables be passed
#    in.
# Exports:
#   Passthrough:
#     * asset_host
#   Headers:
#     * via - Used to check if the proxy is making a request to itself
#     * host - Used to make sure the host was rewritten
#     * user_agent - The device used to make the request OR the fixed value
#     * cookie - The cookie header of the incoming request
#   Other:
#     * method - The http request method (Usually GET or POST).
#     * path - The path to the resource (Full URL in the case of proxy requests)
#     * secure - True if the request should be made via SSL.
#     * source_host - The upstream host to issue the request to.
# Special
#  * Adds the Via and Connection headers if they don't exist.

# Export passthrough variables
{{if .Asset_Host}}
export("asset_host", "{{.Asset_Host}}")
{{else}}
export("asset_host", $asset_host)
{{end}}

{{if .Http11}}
log("Leaving HTTP version alone")
{{else}}
# Set request header to HTTP 1.0
replace(/HTTP\/1\.1/i, "HTTP/1.0")
{{end}}

# Get method and path
replace(/\A(\w{3,})\s+(.+)\s+(HTTP\/\d\.\d)/) {
  export("method", $1)
  export("path", $2)
}

# Get downstream ssl header
$secure = "false"
replace(/\s+^x\-moov\-secure[^\r\n]*/i) {
  $secure = "true"
}
export("secure", $secure)
{{if .User_Agent }}
# Rewrite the user agent
replace(/^(user-agent\:\s*)([^\r\n]*)/i) {
  set("$1")
  append("{{.User_Agent}}")
  # Reset the export (Not sure if this is what we want)
  export("user_agent", "{{.User_Agent}}")
}
{{else}}
# Get the user-agent header
replace(/^user-agent\:\s*([^\r\n]*)/i) {
  export("user_agent", $1)<commit_msg>Force HTTP 1.1<commit_after>$use_global_replace_vars = "true"
#       !!! WARNING THIS FILE IS GENERATED AND PROJECT SPECIFIC !!!
#
# Transform the request from a downstream client so it is ready to issue to the
# upstream host. This script exports variables relevent to processing the
# request. These files are generated and project specific.
#
# Inputs:
#  * The raw http request header (without the \r\n\r\n separator)
#  * This script listens to the X-Moov-Secure header to determine if the request
#    should be issued via SSL.
#  * Optionally the accept_encoding variable can be specified to set the
#    supported compression methods such as "gzip,deflate"
#  * This script does not currently require any enviroment variables be passed
#    in.
# Exports:
#   Passthrough:
#     * asset_host
#   Headers:
#     * via - Used to check if the proxy is making a request to itself
#     * host - Used to make sure the host was rewritten
#     * user_agent - The device used to make the request OR the fixed value
#     * cookie - The cookie header of the incoming request
#   Other:
#     * method - The http request method (Usually GET or POST).
#     * path - The path to the resource (Full URL in the case of proxy requests)
#     * secure - True if the request should be made via SSL.
#     * source_host - The upstream host to issue the request to.
# Special
#  * Adds the Via and Connection headers if they don't exist.

# Export passthrough variables
{{if .Asset_Host}}
export("asset_host", "{{.Asset_Host}}")
{{else}}
export("asset_host", $asset_host)
{{end}}

{{if .Http11}}
# Set request header to HTTP 1.1
replace(/HTTP\/1\.0/i, "HTTP/1.1")
{{else}}
# Set request header to HTTP 1.0
replace(/HTTP\/1\.1/i, "HTTP/1.0")
{{end}}

# Get method and path
replace(/\A(\w{3,})\s+(.+)\s+(HTTP\/\d\.\d)/) {
  export("method", $1)
  export("path", $2)
}

# Get downstream ssl header
$secure = "false"
replace(/\s+^x\-moov\-secure[^\r\n]*/i) {
  $secure = "true"
}
export("secure", $secure)
{{if .User_Agent }}
# Rewrite the user agent
replace(/^(user-agent\:\s*)([^\r\n]*)/i) {
  set("$1")
  append("{{.User_Agent}}")
  # Reset the export (Not sure if this is what we want)
  export("user_agent", "{{.User_Agent}}")
}
{{else}}
# Get the user-agent header
replace(/^user-agent\:\s*([^\r\n]*)/i) {
  export("user_agent", $1)
{'fraction_non_alphanumeric': 0.14208360407190818, 'fraction_numerical': 0.007364089235434265, 'mean_word_length': 3.5185909980430528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1559637', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1482, 'n_words': 555}