Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionServeController.php
Show First 20 Lines • Show All 872 Lines • ▼ Show 20 Lines | private function getMercurialArguments() { | ||||
$args_raw = array(); | $args_raw = array(); | ||||
for ($ii = 1;; $ii++) { | for ($ii = 1;; $ii++) { | ||||
$header = 'HTTP_X_HGARG_'.$ii; | $header = 'HTTP_X_HGARG_'.$ii; | ||||
if (!array_key_exists($header, $_SERVER)) { | if (!array_key_exists($header, $_SERVER)) { | ||||
break; | break; | ||||
} | } | ||||
$args_raw[] = $_SERVER[$header]; | $args_raw[] = $_SERVER[$header]; | ||||
} | } | ||||
$args_raw = implode('', $args_raw); | |||||
if ($args_raw) { | |||||
$args_raw = implode('', $args_raw); | |||||
return id(new PhutilQueryStringParser()) | return id(new PhutilQueryStringParser()) | ||||
->parseQueryString($args_raw); | ->parseQueryString($args_raw); | ||||
} | } | ||||
// Sometimes arguments come in via the query string. Note that this will | |||||
// not handle multi-value entries e.g. "a[]=1,a[]=2" however it's unclear | |||||
// whether or how the mercurial protocol should handle this. | |||||
$query = idx($_SERVER, 'QUERY_STRING', ''); | |||||
$query_pairs = id(new PhutilQueryStringParser()) | |||||
->parseQueryString($query); | |||||
foreach ($query_pairs as $key => $value) { | |||||
// Filter out private/internal keys as well as the command itself. | |||||
if (strncmp($key, '__', 2) && $key != 'cmd') { | |||||
$args_raw[$key] = $value; | |||||
} | |||||
} | |||||
// TODO: Arguments can also come in via request body for POST requests. The | |||||
// body would be all arguments, url-encoded. | |||||
return $args_raw; | |||||
} | |||||
private function formatMercurialArguments($command, array $arguments) { | private function formatMercurialArguments($command, array $arguments) { | ||||
$spec = DiffusionMercurialWireProtocol::getCommandArgs($command); | $spec = DiffusionMercurialWireProtocol::getCommandArgs($command); | ||||
$out = array(); | $out = array(); | ||||
// Mercurial takes normal arguments like this: | // Mercurial takes normal arguments like this: | ||||
// | // | ||||
// name <length(value)> | // name <length(value)> | ||||
▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0