#18341 closed enhancement (fixed)

BUrl class should have a parameter generator

Reported by: tclaus Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Network Kit Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The Burl class has several functions to build a URL.

For API Get requests URLs often have a bunch of additional parameters like ?Q=haiku&page=1&size=10, called "request" ist BUrl documentation.

However it is possible to set a request. But to get more use of the URL, I request a kind of "AddRequest(String &key, String &Value)" method.

Today a developer has to do this task over and over again outside the BUrl and appending strings together.

Change History (6)

comment:1 by pulkomandy, 21 months ago

The BUrl class implements URLs as defined in https://www.rfc-editor.org/rfc/rfc3986

As you can see in section 3.4, the 'key=value separated by &' use of Query is not, in fact, specified in this document. It is just a common use of it in the case of the HTTP protocol.

So, this is indeed implemented in a class specific to HTTP: BHttpForm: https://cgit.haiku-os.org/haiku/tree/headers/private/netservices/HttpForm.h

You can use BHttpForm::AddString to add your key-value pairs, and then BHttpForm::RawData to generate the query string (and then embed it into an URL if you wish to).

comment:2 by waddlesplash, 21 months ago

Component: - GeneralKits/Network Kit

comment:3 by waddlesplash, 21 months ago

Keywords: BUrl removed

comment:4 by waddlesplash, 21 months ago

I guess there is nothing else to do here, and this can be closed?

comment:5 by tclaus, 21 months ago

Thanks for this information. A private class was not what I expected. But this will do the job. Maybe mention this somewhere in the network docs? This ticket, however, can be closed

comment:6 by pulkomandy, 21 months ago

Resolution: fixed
Status: newclosed

Yes, this is in "private" because that part of the "netservices" kit is not considered stable API yet. It will probably be modified in the future (in fact there is already a "netservices 2" rewrite in progress).

That does not prevent using it from 3rd party apps, the code is shipped in a static library so that your app will include a copy of it, and if we change our implementation in future releases, your app will still use the old one it was compiled with.

We should indeed document this class and maybe refer to it in BUrl "query" documentation.

Note: See TracTickets for help on using tickets.