1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace POData\BatchProcessor; |
6
|
|
|
|
7
|
|
|
use POData\OperationContext\HTTPRequestMethod; |
8
|
|
|
use POData\OperationContext\Web\IncomingRequest; |
9
|
|
|
|
10
|
|
|
class IncomingChangeSetRequest extends IncomingRequest |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
protected $contentID = null; |
14
|
|
|
|
15
|
|
|
public function __construct(string $requestChunk) |
16
|
|
|
{ |
17
|
|
|
list($RequestParams, $requestHeaders, $RequestBody) = explode("\n\n", $requestChunk); |
18
|
|
|
|
19
|
|
|
$headerLine = strtok($requestHeaders, "\n"); |
20
|
|
|
$RequestBody = trim($RequestBody); |
21
|
|
|
list($RequesetType, $RequestPath, $RequestProticol) = explode(' ', $headerLine, 3); |
22
|
|
|
$inboundRequestHeaders = []; |
23
|
|
|
$headerLine = strtok("\n"); |
24
|
|
|
|
25
|
|
|
while ($headerLine !== false) { |
26
|
|
|
list($key, $value) = explode(':', $headerLine); |
27
|
|
|
$name = strtr(strtoupper(trim($key)), '-', '_'); |
28
|
|
|
$value = trim($value); |
29
|
|
|
$name = substr($name, 0, 5) === 'HTTP_' || $name == 'CONTENT_TYPE' ? $name : 'HTTP_' . $name; |
30
|
|
|
if ('HTTP_CONTENT_ID' === $name) { |
31
|
|
|
$this->contentID = $value; |
32
|
|
|
} else { |
33
|
|
|
$inboundRequestHeaders[$name] = $value; |
34
|
|
|
} |
35
|
|
|
$headerLine = strtok("\n"); |
36
|
|
|
} |
37
|
|
|
$host = $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? $_SERVER['SERVER_ADDR'] ?? 'localhost'; |
38
|
|
|
$protocol = $_SERVER['PROTOCOL'] = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http'; |
39
|
|
|
|
40
|
|
|
parent::__construct( |
41
|
|
|
new HTTPRequestMethod($RequesetType), |
42
|
|
|
[], |
43
|
|
|
[], |
44
|
|
|
$inboundRequestHeaders, |
45
|
|
|
null, |
46
|
|
|
$RequestBody, |
47
|
|
|
$protocol . '://' . $host . $RequestPath |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getContentId(): ?string |
52
|
|
|
{ |
53
|
|
|
return $this->contentID; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|