Simple HTTP example#101
Conversation
| u8 ssl_init=HTTP_NO; | ||
|
|
||
| //init | ||
| ret = sysModuleLoad(SYSMODULE_NET); |
There was a problem hiding this comment.
netInitialize() does the module loading for you, so you shouldn't need to do this + netInitialize() in theory?
s32 netInitialize()
{
//....
ret = sysModuleLoad(SYSMODULE_NET);
if(ret<0) return lv2errno(ret);
//....
return ret;
}
There was a problem hiding this comment.
yes, I know it's not needed, but my criteria for samples is to be as verbose and explicit as possible. My goal here is (hopefully 🙏 ) to help someone to learn, not to achieve the best http-fetch library. 😄
I think that an example should be easy to understand for any newcomer who doesn't have a clue about the internals of a library or SDK. (E.g., If I remove the line, the user might never know there's a SYSMODULE_NET at all)
In that sense, the code is surely un-optimized in many ways (it uses many variables, prints messages for each error, etc.), but hopefully it will give an overview of the main stuff available in libhttp.
Anyways, all feedback is appreciated 👍
There was a problem hiding this comment.
lol ok! I wasn't sure if it could potentially be an issue for an app to try and load a sys module multiple times!
There was a problem hiding this comment.
No, actually that's one of the things SCE took care in their design. You can request to load modules many times, and the system takes care of dependencies and all.
For example: if you try to load SYSMODULE_HTTPS directly (and nothing was loaded before), the PS3 will load NET, HTTP, and SSL modules along with HTTPS.
For unloading, the system also check if the modules are still in use or have cross dependencies, to avoid issues. (another nice feature)
There was a problem hiding this comment.
Oh nice that's really good to know, thanks!
| goto end; | ||
| } | ||
|
|
||
| ret = httpInit(http_pools.http_pool, 0x10000); |
There was a problem hiding this comment.
So libnet manages memory for a user (128KB) but for these other libs you have to have your own memory pool for initialization? Interesting, it'd be nice if there was more consistency between the libs, but at the same time I could understand wanting to define your own memory size for the http pool
There was a problem hiding this comment.
well, don't forget we are calling the original PS3 libraries, so the rationale here was defined by SCE. I don't know the details so I can't really answer. The original SDK brings the SCE documentation, and I guess some reasons could be found there.
A basic HTTP/HTTPS example using
libhttp,libssl,libhttputil