FeedParserFile.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace dokuwiki;
  3. use dokuwiki\HTTP\DokuHTTPClient;
  4. /**
  5. * Fetch an URL using our own HTTPClient
  6. *
  7. * Replaces SimplePie's own class
  8. */
  9. class FeedParserFile extends \SimplePie\File
  10. {
  11. protected $http;
  12. /** @noinspection PhpMissingParentConstructorInspection */
  13. /**
  14. * Inititializes the HTTPClient
  15. *
  16. * We ignore all given parameters - they are set in DokuHTTPClient
  17. *
  18. * @inheritdoc
  19. */
  20. public function __construct(
  21. $url,
  22. $timeout = 10,
  23. $redirects = 5,
  24. $headers = null,
  25. $useragent = null,
  26. $force_fsockopen = false,
  27. $curl_options = array()
  28. ) {
  29. $this->http = new DokuHTTPClient();
  30. $this->success = $this->http->sendRequest($url);
  31. $this->headers = $this->http->resp_headers;
  32. $this->body = $this->http->resp_body;
  33. $this->error = $this->http->error;
  34. $this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_FSOCKOPEN;
  35. return $this->success;
  36. }
  37. /** @inheritdoc */
  38. public function headers()
  39. {
  40. return $this->headers;
  41. }
  42. /** @inheritdoc */
  43. public function body()
  44. {
  45. return $this->body;
  46. }
  47. /** @inheritdoc */
  48. public function close()
  49. {
  50. return true;
  51. }
  52. }