Skip to content

Commit

Permalink
Log the OPTIONS response.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Mar 10, 2017
1 parent e7d646e commit 05d3a8d
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions framework/ActiveSync/lib/Horde/ActiveSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ public function handleRequest($cmd, $devId)
// Device id is REQUIRED
if (empty($devId)) {
if ($cmd == 'Options') {
$this->_doOptionsRequest();
$this->_handleOptionsRequest();
$this->_driver->clearAuthentication();
return true;
}
Expand Down Expand Up @@ -972,40 +972,56 @@ protected function _handleDevice($devId)

/**
* Send the MS_Server-ActiveSync header.
*
* @return array Returns an array of the headers that were sent.
* @since 2.39.0
*/
public function activeSyncHeader()
{
header('Allow: OPTIONS,POST');
header('Server: Horde_ActiveSync Library v' . self::LIBRARY_VERSION);
header('Public: OPTIONS,POST');
$headers = array(
'Allow: OPTIONS,POST',
sprintf('Server: Horde_ActiveSync Library v%s', self::LIBRARY_VERSION),
'Public: OPTIONS,POST'
);

switch ($this->_maxVersion) {
case self::VERSION_TWOFIVE:
header('MS-Server-ActiveSync: 6.5.7638.1');
$headers[] = 'MS-Server-ActiveSync: 6.5.7638.1';
break;
case self::VERSION_TWELVE:
header('MS-Server-ActiveSync: 12.0');
$headers[] = 'MS-Server-ActiveSync: 12.0';
break;
case self::VERSION_TWELVEONE:
header('MS-Server-ActiveSync: 12.1');
$headers[] = 'MS-Server-ActiveSync: 12.1';
break;
case self::VERSION_FOURTEEN:
header('MS-Server-ActiveSync: 14.0');
$headers[] = 'MS-Server-ActiveSync: 14.0';
break;
case self::VERSION_FOURTEENONE:
header('MS-Server-ActiveSync: 14.1');
$headers[] = 'MS-Server-ActiveSync: 14.1';
break;
case self::VERSION_SIXTEEN:
header('MS-Server-ActiveSync: 16.0');
$headers[] = 'MS-Server-ActiveSync: 16.0';
}

foreach ($headers as $hdr) {
header($hdr);
}

return $headers;
}

/**
* Send the protocol versions header.
*
* @return string The header that was sent. @since 2.39.0
*/
public function versionHeader()
{
header('MS-ASProtocolVersions: ' . $this->getSupportedVersions());
$hdr = sprintf('MS-ASProtocolVersions: %s', $this->getSupportedVersions());
header($hdr);

return $hdr;
}

/**
Expand All @@ -1021,10 +1037,15 @@ public function getSupportedVersions()

/**
* Send protocol commands header.
*
* @return string The header that was sent. @since 2.39.0
*/
public function commandsHeader()
{
header('MS-ASProtocolCommands: ' . $this->getSupportedCommands());
$hdr = sprintf('MS-ASProtocolCommands: %s', $this->getSupportedCommands());
header($hdr);

return $hdr;
}

/**
Expand Down Expand Up @@ -1171,11 +1192,15 @@ public function contentTypeHeader($content_type = null)
/**
* Send the OPTIONS request response headers.
*/
protected function _doOptionsRequest()
protected function _handleOptionsRequest()
{
$this->activeSyncHeader();
$this->versionHeader();
$this->commandsHeader();
$as_headers = implode("\r\n", $this->activeSyncHeader());
$version_header = $this->versionHeader();
$cmd_header = $this->commandsHeader();
$this->_logger->meta(sprintf(
"Returning OPTIONS response:\r\n%s\r\n%s\r\n%s",
$as_headers, $version_header, $cmd_header)
);
}

/**
Expand Down

0 comments on commit 05d3a8d

Please sign in to comment.