realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

Automatically added slash symbol causes a problem with github API #715

Open tapanij opened 11 years ago

tapanij commented 11 years ago

Get JSON from the github api: RequestAsset("https://api.github.com/repos/mojombo/jekyll/issues", "Binary");

ERROR: Error: Transfer of asset "Binary", name "https://api.github.com/repos/mojombo/jekyll/issues" failed! Reason: "Http GET for address "https://api.github.com/repos/mojombo/jekyll/issues/" returned an error: Error downloading https://api.github.com/repos/mojombo/jekyll/issues/ - server replied: Not Found"

CAUSE: Slash is added to end of the URL automatically. Because of this github api couldn't find the JSON file.

WORKAROUND: Add question mark to the end of the URL: RequestAsset("https://api.github.com/repos/mojombo/jekyll/issues?", "Binary");

jonnenauha commented 11 years ago

Hmm, I don't think we add that slash automatically. Qt might if it thinks its a directory?

This logic might actually append the last / if it thinks its a folder. Would need to look closer to be sure https://github.com/realXtend/naali/blob/tundra2/src/Core/AssetModule/HttpAssetProvider.cpp?source=c#L131-L139

Imo that logic should be removed as IAsset::RequestAsset and IAssetBundle takes care of that no refs that has subassetref will be requested directly from the providers!

erno commented 11 years ago

AssetAPI::ParseAssetRef has this:

QString path = GuaranteeTrailingSlash(fullPathRef.left(directorySeparatorIndex+1).trimmed());

.. protocol_path += path; .. if (outFullRefNoSubAssetName) *outFullRefNoSubAssetName = GuaranteeTrailingSlash(protocol_path) + assetFilename;

and HttpAssetProvider is using the param called (on that side) &assetRefWithoutSubAssetName...

Also the "www." hack and the "\" -> "/" replacement look a little iffy to me since they cause asset refs to be interpreted differently in different contexts. Could be used to get around script based whitelisting etc.