Skip to content

Simple HTTP example#101

Merged
miigotu merged 1 commit into
ps3dev:masterfrom
bucanero:http-example
Jul 3, 2020
Merged

Simple HTTP example#101
miigotu merged 1 commit into
ps3dev:masterfrom
bucanero:http-example

Conversation

@bucanero

@bucanero bucanero commented Jul 2, 2020

Copy link
Copy Markdown

A basic HTTP/HTTPS example using libhttp , libssl, libhttputil

u8 ssl_init=HTTP_NO;

//init
ret = sysModuleLoad(SYSMODULE_NET);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@bucanero bucanero Jul 3, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice that's really good to know, thanks!

goto end;
}

ret = httpInit(http_pools.http_pool, 0x10000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@miigotu miigotu merged commit 862c7eb into ps3dev:master Jul 3, 2020
miigotu pushed a commit that referenced this pull request Jul 3, 2020
@bucanero bucanero deleted the http-example branch July 3, 2020 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants