Provide IFile consumers a rudimentary HTTP POST option #1572

wants to merge 3,110 commits into


None yet

Currently binary addons can not access and use the full functionality provided by CCurlFile to access a webservice.

eg. PVR addons can use a simple GET via the IFile interface by using the sequence:

  • Open
  • ReadString or Read (until data is exhausted)
  • Close

This change extends that with a very rudimentary support for POST with post data via the IFile interface by using the sequence:

  • Open
  • Write (postdata)
  • ReadString or Read (until data is exhausted)
  • Close

What's not pretty? Content-Type is hard coded to application/json at this time. In a future version this might be configurable by allowing headers to be added via IoControl (IOCTRL_NATIVE).

fix: allow post with postdata length of zero bytes
fix: SetMimeType didn't work
added: implementation of IFile's OpenForWrite and Write methods

margro and others added some commits Apr 5, 2012
@margro margro MediaPortal pvr addon: fix compile error bd77b07
@margro margro XVDR pvr addon: add local version of the old libPlatform/libTcpSocket…
… code for now...
@opdenkamp opdenkamp Merge pull request #499 from TheChief79/8da31a8ab6aea712e45ea18d0a985…

Fixed XCode projects for OSX, iOS and ATV2
Marcel Groothuis ForTheRecord pvr addon: Linux compile fixes d5af7b5
@Red-F Red-F [pvrfortherecord] This fixes a non-trivial memory leak of > 10KB/min …
…on Windows
Marcel Groothuis ForTheRecord pvr addon: update version number and changelog for switc…
…h to platform library
@Red-F Red-F Merge remote-tracking branch 'origin/master' 8aba358
@Red-F Red-F [pvrfortherecord] start of simplification of TSReader to a minimal ve…
…rsion that only supports linear reading (ie. no internal timeshift support)
@Red-F Red-F [pvrfortherecord] further simplification of TSreader classes ac5888d
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'. Needs xcode sync
@opdenkamp opdenkamp pvr: fix GetLevel() calls in dvdplayer 88e5249
@Red-F Red-F [pvrfortherecord] simplified tsreader on Linux 67e2599
@Red-F Red-F Merge remote-tracking branch 'upstream/master'
@margro margro MediaPortal pvr addon: fix a small memory leak in the MultiFileReader 5926411
@margro margro pvr: fix segfault when using the "Reset the EPG database" option with…
… the PVRManager already disabled.
@margro margro MediaPortal pvr addon: don't import the "All Channels" group because …
…it duplicates the internal "All Channels" group.
Jörg Dembski vuplus-addon: update to 0.1.12 ebfe114
@margro margro Merge remote-tracking branch 'jdembski/master'
Skip curl binaries and headers.
@margro margro VuPlus pvr addon: fix Windows compilation and re-use the libcurl libr…
…ary from ForTheRecord
@margro margro VuPlus pvr addon: put compiled pvr addon in the addon dir also for th…
…e release build
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@opdenkamp opdenkamp pvr: fix CDVDInputStream::NextStream() override after the merge 8d007da
@Red-F Red-F [pvrfortherecord] fix for new PLATFORM:: thread class that doesn't li…
…ke Stopping during long Sleeps
@Red-F Red-F Merge remote-tracking branch 'origin/master' into simplets
@Red-F Red-F [pvrfortherecord] less create/destroy keepalive thread activity on tu…

Stop live stream and then re-tune when FTR tells us it can not re-tune
with a running live stream.
@Red-F Red-F [pvrfortherecord] version and changelog updated 94f8fc2
@Red-F Red-F Merge remote-tracking branch 'origin/master' into simplets 90f3fb4
@margro margro Merge remote-tracking branch 'red-f/master' 8740032
@margro margro MediaPortal pvr addon: fix start date and time for instant recordings e3bbd36
@margro margro Merge remote-tracking branch 'opdenkamp/master' c66388c
@margro margro Remove unneeded configurations from Windows solution 4e16fa5
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@pipelka pipelka pvr: fix recording path for subdirectories 6e39674
@pipelka pipelka pvr: fixed deadlock on creating thumbnails 2785120
@opdenkamp opdenkamp Merge branch 'PR506'. closes #506 5a04fee
@jajoflo jajoflo Set folder date to the date of the most recent recording it contain. 6a0aae1
@opdenkamp opdenkamp Merge branch 'PR501'. closes #501 53d808a
@nemphys nemphys epg: new channel context menu item in channel groups that allows upda…
…ting of EPG information for specific channel on demand
@opdenkamp opdenkamp Merge branch 'PR488'. closes #488 7bc746d
@mikrohard mikrohard Don't delete groups added by the user with XBMC 5bf6c3f
@Red-F Red-F small fix for libblyray error message on wrong angle api, comma and '…
…if' were messing configure up (even after quoting)
@Red-F Red-F Merge remote-tracking branch 'origin/master' into simplets fff3b38
@margro margro Merge remote-tracking branch 'opdenkamp/master' 4d93cce
@margro margro XVDR pvr addon: update to latest version from Pipelka.
Source updated to 75445e74198cb5b8d94a4d324c36432ecc7c6517 (01-04-2012)
@margro margro Update .gitignore 84a6c17
@jajoflo jajoflo 1- All schedule program are now list in the Timer view.
2- Proper next recording will always be shown properly.
@jajoflo jajoflo Show the right info for currently program(s). 7be0a86
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master' 3dc0b3c
@margro margro MediaPortal pvr addon: cross platform changes and cosmetics
- timeout via CTimeout
- typedef for wchar_t because it has different sizes on Windows and Linux
@margro margro Update VS2010 solution c2aa396
@margro margro MediaPortal pvr addon: switch to PLATFORM::Thread a05d0a9
@margro margro MediaPortal pvr addon: remove InfoFile support to cleanup FileReader …

I've never seen .info files with recent MediaPortal versions, so it probably safe to remove this.
@margro margro ForTheRecord libcurl (win32): update sources to v7.21.6 to match Wind…
…ows builddeps
@margro margro pvrclients (win32): move shared libcurl to shared lib folder 87eb74d
@margro margro MediaPortal pvr addon: add 5 s timeout for waiting on RTSP data. 2bbeec1
@margro margro MediaPortal pvr addon: merge tsreader cross platform changes from new…
…threads2 branch (part 1)
@margro margro MediaPortal pvr addon: tsreader and ffmpeg addons are now combined in…
…to one addon
@mikrohard mikrohard Change bIsUserSetGroup to iGroupType to be more flexible in the future 81ac553
@tsp tsp ADDED: Initial support for working timeshift. 11e6425
@margro margro MediaPortal pvr addon: work in progress: seek support for recordings …
…and livestreams
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master' 95ecfd4
@opdenkamp opdenkamp pvr: sync with PR 860 111d12e
@margro margro MediaPortal pvr addon: fix tsreader segfault under Linux (add missing…
… sources to the Makefile)
@nemphys nemphys epg: also update channel info on child epg infotags when updating epg…
… table through UpdateMetadata method. Fixes missing channel info from epg infotags when epg is loaded from the db first and then updated by pvr manager.
@nemphys nemphys pvr: add a Start/Stop Recording context menu item to pvr channels in …
…channel list view
@opdenkamp opdenkamp Merge branch 'PR510'. closes #510 d3cb7ab
@opdenkamp opdenkamp Merge branch 'PR511'. closes #511 65e77d6
@opdenkamp opdenkamp Merge pull request #512 from mikrohard/user_defined_groups
Don't delete groups added by the user with XBMC
@opdenkamp opdenkamp Merge pull request #515 from jajoflo/fixe_current_recording_for_Upstream
Show the right info for currently recording  program(s).
@fetzerch fetzerch Added context menu entry that allows to mark recordings as watched / …
@margro margro Merge pull request #18 from jajoflo/add_prog_id
Add progid
@tsp tsp FIX: missing else in CPVRClients::GetStreamPosition(). Thanks to dodo…
…adoodoo for noticing it.
@Red-F Red-F [pvrfortherecord] Introducing the read position c75d070
@margro margro Merge remote-tracking branch 'opdenkamp/master' 2068f5e
@margro margro MediaPortal pvr addon: fix segfault under Linux when reading the genr…
…e string table

Switched to TinyXML2 because the segfault occurred inside tinyxml.
@margro margro Mediaportal pvr addon: cosmetics and code cleanup 1a3dff1
@margro margro MediaPortal pvr addon: add experimental support for timeshifting 2f3f7ad
@Red-F Red-F Merge remote-tracking branch 'upstream/master'
@Red-F Red-F fix merge overview 83debc5
fred Merge branch 'master' into simplets 86bf437
fred [pvrfortherecord] fix: remove local scoped re-declaration bb5d9f1
fred [pvrfortherecord] Added configurable delay in milliseconds after tuni…
…ng a new channel
@Red-F Red-F [pvrfortherecord] setting renamed from 'delay' into 'tunedelay' 0c53e96
@Red-F Red-F fix: treat setting type 'number' like 'integer' 2885eab
@margro margro dll addons: settings type "integer" should be "number" f8e12d5
@margro margro Vu plus pvr addon: update to v0.2.2
@margro margro pvr: fixed: radio channel timers were not shown because XBMC could no…
…t find the corresponding channel
@Red-F Red-F Merge remote-tracking branch 'upstream/master' 048b33b
@Red-F Red-F Merge branch 'master' into simplets
@Red-F Red-F [pvrfortherecord] Change log and version updated for optimised TsReader
and new configurable post-tune delay
@Red-F Red-F [pvrfortherecord] support 'openrecordedstream' etc. on non-windows too 8a4ae66
@margro margro MediaPortal pvr addon: simplify settings; the backend now reports the…
… Timeshift and Recordings shares

The settings to override the Timeshift folder and Recordings folder are removed now.
The 'userecordingsdir' and 'directtsfileread' settings are replaced by a single 'usertsp' setting.
Note: this update requires an update to TVServerXBMC build 115 for multi-seat setups.
@margro margro MediaPortal pvr addon: tsreader: add Live555 RTSP support for Linux eaad103
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'. Only English and Dutch tran…
…slations have been converted. Other translations need to be re-added. Needs xcode sync

	project/VS2010Express/XBMC for Windows.sln
@opdenkamp opdenkamp pvr/epg: use system tinyxml f075e8c
@opdenkamp opdenkamp dropped mythtv PVR client ed7c6cc
@Red-F Red-F [pvrfortherecord] use the unicode version of CreateFile on Windows to…
… handle filenames that contain non-ansi charactars (eg. Polish names)
@Red-F Red-F [pvrfortherecord] Version update for national character support fix 3034a64
@Red-F Red-F Merge remote-tracking branch 'upstream/master' 828f815
@Red-F Red-F [pvrfortherecord] finally created a makefile that no longer produces …
…make warnings like "warning: overriding commands for target `.....'"
opdenkamp and others added some commits Jun 15, 2012
@opdenkamp opdenkamp Merge remote branch 'fetzerch/feature-pvr-markwatched-menu' into PR508
@opdenkamp opdenkamp pvr: fixes for PR508. two possible crashes and don't display a nasty …
…warning if the backend doesn't support this feature
@opdenkamp opdenkamp Merge branch 'PR508' + fixes. closes #508 ac181de
@mikrohard mikrohard EpgContainer: Fix next ID size when loading from db and remove old/un…
…used epg channels

Signed-off-by: Jernej Fijačko <>
@opdenkamp opdenkamp Merge branch 'PR543'. closes #543 7dc374d
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master' 8961c69
@opdenkamp opdenkamp Merge pull request #539 from mikrohard/guiepggrid_fix
GUIEPGGridContainer: Prevent crash if there is only one channel with epg
@margro margro Merge remote-tracking branch 'opdenkamp/master'
Conflicts solved:
@margro margro pvr addons: add empty SetRecordingPlayCount() function to the FTR, Vu…
…Plus and XVDR addons.

This new function was introduced in the previous merge commit.
@mikrohard mikrohard GUIEditControl - add numeric new password verify needed by PVR parent…
…al control settings
@mikrohard mikrohard GUIViewControl - add flag to force refresh view be6c3ae
@mikrohard mikrohard PVR - add parental control to channels (with epg) fdd55e9
@opdenkamp opdenkamp pvr: hook the parental lock checks up in OpenLiveStream() and SwitchC…
…hannel(), instead of in all (indirect) calls to those methods. changed the bSettings param of CheckParentalPIN() to strTitle, since it only changes the title of the dialog. also check the parental locks when creating timers. cleanups
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master' d739d9f
@opdenkamp opdenkamp Merge branch 'PR507' + fixes. closes #507 96d6865
@mikrohard mikrohard PVRTimers: Prevent use of uninitialised dailywakeuptime dc770ec
@mikrohard mikrohard PVR: Call power saving wakeup script also on suspend and hibernate (n…
…ot only shutdown)
@opdenkamp opdenkamp Merge branch 'PR544'. closes #544 9244310
@opdenkamp opdenkamp PVR Api extended with lastplayed position management for recordings,
GetRecordingLastPlayedPosition will return the last watched position of
a recording in seconds (-1 on error/not implemented),
SetRecordingLastPlayedPosition will store the last watched position in
seconds for a recording.


@opdenkamp opdenkamp Merge branch 'PR536'. closes #536 adaffe4
@margro margro Merge remote-tracking branch 'opdenkamp/master'
Conflicts solved:
@margro margro pvr addons: update for recent PVR API extension: Get/SetRecordingLast…
@opdenkamp opdenkamp epg: fix possible deadlock in CEpgInfoTag::Icon() and some other EPG …
…table related calls from CEpgInfoTag. closes #549
@margro margro MediaPortal pvr addon: update Korean translation 4c373e7
@margro margro Merge remote-tracking branch 'opdenkamp/master' 6e3a1fe
@margro margro PVR addons: add missing 'bSupportsLastPlayedPosition' property to Get…
…AddonCapabilities function

Affected addons: ForTheRecord, VuPlus and XVDR
@margro margro MediaPortal pvr addon: Extend recording title with episode informatio…
…n when the title resembles the subfolder name

This typically adds the episode name to the title of series
@margro margro MediaPortal pvr addon: prevent rewinding to the previous channel
This gives problems when the stream count and types change.
@margro margro pvr: workaround to fix rendering timeouts bd4ef2d
@margro margro VuPlus pvr addon: update to 0.2.8 7f23314
@margro margro platform: import StdString.h fixes from XBMC c15e9f9
@margro margro MediaPortal pvr addon: fix missing symbols on Darwin 0938783
@mikrohard mikrohard GUIWindowPVRChannels: toggle recording on channel only when button is…
viking1 pvr: re-added Finnish translation for core and Confluence strings
these were removed in commit 3203d89
@opdenkamp opdenkamp Merge pull request #560 from viking1/pvr-translation
Finnish PVR translation
@opdenkamp opdenkamp Merge pull request #558 from mikrohard/patch-3
GUIWindowPVRChannels: toggle recording on channel only when button is CONTEXT_BUTTON_RECORD_ITEM
@benkibbey benkibbey Fix timed recording. 4bbbe47
@xhaggi xhaggi pvr: german translation 55f81df
@opdenkamp opdenkamp Merge pull request #567 from xhaggi/german-translation
pvr: german translation
@opdenkamp opdenkamp Merge pull request #561 from benkibbey/master
Fix timed recording.
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@opdenkamp opdenkamp pvr: removed startsync in dvdplayer after 095624e 8d7cffe
@opdenkamp opdenkamp path param moved from CSkinInfo::Start() to the path field in AddonProps 74ff4fe
@opdenkamp opdenkamp epg: don't hold a lock while loading channels from the db. fixes dead…
…lock when entering the livetv window while the epg tables are being loaded from the db
@margro margro Merge remote-tracking branch 'opdenkamp/master' 72bfcd4
@margro margro MediaPortal pvr addon: add Hungarian translation. Credits: Attila Zsigus bc1e276
@tsp tsp ADDED: EPG info and player time is now proper displayed when using ti…
@tsp tsp ADDED: Don't update EPG for hidden channels. Credit goes to dodoadoodoo. c552c55
@margro margro pvr: fixed: recording play count should be an integer a428231
@margro margro pvr: fix compiler warning about double to int conversion 1cf28d1
@opdenkamp opdenkamp epg: back to keeping pointers to CPVRChannel in CEpg and CEpgInfoTag.…
… this introduced a couple of possible deadlock situations
@opdenkamp opdenkamp epg: don't deref a null ptr in CGUIEPGGridContainer::GetSelectedItem() d15b96d
@margro margro pvr/epg: fix wrong reference arguments and a few compiler warnings f05c088
@opdenkamp opdenkamp epg: removed unneeded local time conversions when getting epg data an…
…d cache the fileitemlist with epg entries in the window. speeds up timeline (a lot)
@opdenkamp opdenkamp epg: notify observers when added and deleting a table, and make the e…
…pg container observer epg tables. fixes epg timeline not being updated when tags change
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@opdenkamp opdenkamp epg: fix possible loop and deadlock when updating the epg async 3915c6b
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@margro margro Merge remote-tracking branch 'opdenkamp/master' 03f51af
@margro margro XVDR pvr addon: cleanup VS2010 project file 0343f9c
@xhaggi xhaggi pvr: german translation improved and misspellings fixed 849b424
@opdenkamp opdenkamp Merge pull request #573 from xhaggi/german-translation
pvr: german translation improved and misspellings fixed
@margro margro MediaPortal pvr addon: add Hebrew translation (credits: zivads) 66583e5
@margro margro Merge remote-tracking branch 'opdenkamp/master' ec33523
@margro margro VuPlus pvr addon: update sources for v0.2.8
I forgot to commit the actual updated sources
@opdenkamp opdenkamp Merge remote branch 'upstream-ro/master'
@opdenkamp opdenkamp pvr/epg: added to CDatabaseManager 783d335
@margro margro Merge remote-tracking branch 'opdenkamp/master' 7245f9a
@margro margro Merge remote-tracking branch 'teamxbmc/master' e5558f0
@margro margro Partly revert "change AE definition and usage of GetCacheTime to matc…
…h how it is used in players"

Paplayer playback of mp3's stopped working when using WASAPI after this commit.

This reverts the WASAPI part of commit 78a424d.
@Red-F Red-F Merge branch 'master' into temp b6678f4
@Red-F Red-F Merge remote-tracking branch 'upstream/master' 4354e89
@Red-F Red-F fix: allow post with postdata length of zero bytes
fix: SetMimeType didn't work
added: implementation of IFile's OpenForWrite and Write methods
Team Kodi member

Ok I looked at PR 1567 and it is clear that this PR collides.

This code provides a simple POST, much inline with the simple GET that is already offered by CurFile.

1567 implements a complete new webdav filesystem, perhaps it better inherit from CurlFile and do webdav specific stuff there?

The reason for this PR is that just a couple of weeks ago new policies were enforced for PVR addons where they can no longer use CURL by themselves. All in all this means that one of the oldest PVR addons, that has been in use since december 2010, will not be in Frodo when it is released, unless there is a way to use a RESTfull webservice that can be used from within PVR addons. An alternative would be to have CurlFile available via the PVR api.

Any help, ideas or suggestions are appreciated.


Team Kodi member
@opdenkamp opdenkamp referenced this pull request in opdenkamp/xbmc-pvr-addons Oct 10, 2012

ForTheRecord addon updated to v0.0.1.142 #34


Ok, not being a native English speaker I have to choose my wording carefully.

I took time to carefully examine the CurlFile.h/cpp. 1567 does not implement POST but PUT (it uses CURLOPT_UPLOAD, not CURLOPT_POST). Actually POST is already supported by CurlFile, just not via the generic IFile interface.

To me it would make more sense to have a POST within CurlFile, and create separate overrides of the virtual WriteFile and Write methods within the webdav class to upload files (which is what webdav is about ultimately). The 1567 PR already makes private fields and methods protected. Thus he has access to all the CurlFile features to implement the webdav class. True users of the generic IFile interface are very limited.

For access to most REST webservices GET and POST would be sufficient and this implementation within CurlFile provides just that for generic http/https urls. Specific (legacy) webservices (protocols) like eg. webdav need specific support, and it looks like the webdav filesystem of 1567 brings that. But, as I said, I would just move the PUT into the webdav subclass, and leave CurlFile minimally impacted while providing a tad more support for POST to users of the limited interface. And move the protocol specific upload to the webdav subclass.

If I'm wrong about 1567 not implementing post please tell me.


Team Kodi member

Agreed, we're trying to get a lot of functionality via a minimalistic interface.

There are, however, not too many options when you're writing a PVR addon (and do not want to static link to full CURL). The 'old' way used to link to the curl shared object. But distribution gets complicated that way because of version mismatches. One really just wants to be dependent on XBMC and nothing else.

An alternative would be to extend the PVR api... I'm sure that will not be greeted with pleasure at this moment in time.

(Actually I even considered a 'rest://' protocol with the factory returning an instance of a RESTFile subclass of CurlFile. However due to the IFile limitations there would not be much benefit.)


So, how do we proceed from here? This is a blocking issue for the completion of the ForTheRecord PVR add-on.

Team Kodi member

in my opinion, do it like this for now, and don't fool around with the API anymore now, and refactor it later on, when and if we need something else.

Team Kodi member

so pushing the green button now @opdenkamp ?

@Red-F - just had a look a the curl code. Can you use/set "m_postdataset" somehow? Seems if this variable is set CURL will configure itself for POST. Also there are header and write callbacks - can those be used? I'm no C++ dev, so I'm just asking/guessing.

edit: or wouldn't it make sense to adjust the existing get/post methods with callbacks and additional headers/mimetype?

Team Kodi member

this PR bites #1567. since this one actually fixes an issue and the other one adds a feature, i'd like to see this go in and look at the new feature (and probably a refactor) later on

Team Kodi member

For the record, I confirm #1567 implements PUT and not POST.
If we need both PUT & POST for different purposes, then OpenForWrite & Write should be in different CurlFile descendants, and we should leave CurlFile read-only.

Or maybe have generic CurlFilePut & CurlFilePost descendants?

Furthermore, based off #1567, write-enabled sftp, ftp, ... is trivial and use CURL_UPLOAD, too. So, IMO, CURL_UPLOAD is really the standard CURL write interface, and POST a http specific sub-protocol.


Perhaps CURL_UPLOAD is really the standard CURL write interface. But current consumers of the IFile interface end up with an instance of CurlFile and limited GET functionality at this moment when they open a http:// protocol url. From that perspective should we re-factor CurlFile and create descendant HTTPFile and DAVFile?

Personally I'm fine with whatever solution surfaces. The problem I really need to be solved is POST functionality from within PVR addons. It is a blocking issue. And I imagine the less code changed the better at this stage.

Team Kodi member

I understand the concern re less code change is better, but indeed, IMO, the cleanest solution would be to leave CurlFile with CURL_UPLOAD and have a HTTPFile (or HTTPFormFile?) which would implement POST. @elupus ?

Besides, this way, the clash with #1567 could be averted, would it deemed mergeable for frodo

Team Kodi member

That implies removing GET from CurlFile too...

Team Kodi member

Why so? The "read" of libcurl (i.e. the default action) is always translated as a http GET...


I guess it must be a personal preference, because the current CurlFile already has a .post() method, replicating POST in a sub-class just for IFile:: OpenForWrite/Write feels... I don't know, sloppy.

Anyhow, as long as everybody understands, and is happy with, the fact that the factory will return a different class for http:// protocols then before, it doesn't really matter to me. I just really, really need an agreed upon way to POST so that I can finally start working on bringing the addon on par with the current PVR API level.

Team Kodi member

My fifty cent on this is that I want the mulitibased interface in the other pull request with PUT/POST being selected by protocol options.

@Red-F Red-F closed this Oct 20, 2012

In response to the above comments I have re-implented this functionality in a subclass and replaced this PR with PR #1650. This should no longer clash with PR #1567.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment