mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:46:24 +08:00
dlna: correct output for ContentDirectoryService#Browse with BrowseMetadata
We were marshalling the "cds object" instead of the "upnp object". Fixes #3253 (I think)
This commit is contained in:
parent
fd4b25932c
commit
8c038326b9
|
@ -245,7 +245,15 @@ func (cds *contentDirectoryService) Handle(action string, argsXML []byte, r *htt
|
|||
"UpdateID": cds.updateIDString(),
|
||||
}, nil
|
||||
case "BrowseMetadata":
|
||||
result, err := xml.Marshal(obj)
|
||||
node, err := cds.vfs.Stat(obj.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
upnpObject, err := cds.cdsObjectToUpnpavObject(obj, node, host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result, err := xml.Marshal(upnpObject)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/rclone/vfs"
|
||||
|
@ -91,3 +92,32 @@ func TestServeContent(t *testing.T) {
|
|||
|
||||
require.Equal(t, goldenContents, actualContents)
|
||||
}
|
||||
|
||||
// Check that ContentDirectory#Browse returns appropriate metadata on the root container.
|
||||
func TestContentDirectoryBrowseMetadata(t *testing.T) {
|
||||
// Sample from: https://github.com/rclone/rclone/issues/3253#issuecomment-524317469
|
||||
req, err := http.NewRequest("POST", testURL+"ctl", strings.NewReader(`
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<s:Body>
|
||||
<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
|
||||
<ObjectID>0</ObjectID>
|
||||
<BrowseFlag>BrowseMetadata</BrowseFlag>
|
||||
<Filter>*</Filter>
|
||||
<StartingIndex>0</StartingIndex>
|
||||
<RequestedCount>0</RequestedCount>
|
||||
<SortCriteria></SortCriteria>
|
||||
</u:Browse>
|
||||
</s:Body>
|
||||
</s:Envelope>`))
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("SOAPACTION", `"urn:schemas-upnp-org:service:ContentDirectory:1#Browse"`)
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(body), "<container ")
|
||||
require.NotContains(t, string(body), "<item ")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user