summaryrefslogtreecommitdiff
path: root/platform/www/inc/FeedParserFile.php
blob: be3417e9ba06dac8aa899883125c5697e1571284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace dokuwiki;

use dokuwiki\HTTP\DokuHTTPClient;

/**
 * Fetch an URL using our own HTTPClient
 *
 * Replaces SimplePie's own class
 */
class FeedParserFile extends \SimplePie_File
{
    protected $http;
    /** @noinspection PhpMissingParentConstructorInspection */

    /**
     * Inititializes the HTTPClient
     *
     * We ignore all given parameters - they are set in DokuHTTPClient
     *
     * @inheritdoc
     */
    public function __construct(
        $url,
        $timeout = 10,
        $redirects = 5,
        $headers = null,
        $useragent = null,
        $force_fsockopen = false,
        $curl_options = array()
    ) {
        $this->http = new DokuHTTPClient();
        $this->success = $this->http->sendRequest($url);

        $this->headers = $this->http->resp_headers;
        $this->body = $this->http->resp_body;
        $this->error = $this->http->error;

        $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;

        return $this->success;
    }

    /** @inheritdoc */
    public function headers()
    {
        return $this->headers;
    }

    /** @inheritdoc */
    public function body()
    {
        return $this->body;
    }

    /** @inheritdoc */
    public function close()
    {
        return true;
    }
}