class Uri

Dear all,

I had a look at QUrl with the intent to see how it could be reused for our class Uri. I wanted to extend QUrl by deriving from it and providing overloads that take QByteArray instead of QString and do not perform any encodings/decodings under the hood (we would need that for TrackerRequestWriter). Unfortunately, QUrl from Qt4.2 does not provide access to its private data. That has been changed in Qt4.3, so we could proceed with Uri after we have moved to Qt4.3.

As the name suggests, although it implements the URI specs, it is more specialized on the URI schemes defined in the URL specs. After a brief look at the implementation there was at least one thing I disliked, namely the query string is stored as a QByteArray and each time queryItems() or queryItemsValue() is called, the raw byte buffer is parsed again. That makes me think whether or not implement class Uri from scratch (probably borrowing some parsing code from QUrl).

My suggestion would be that class Uri only works with QByteArrays. The user would need to perform any encoding/decoding to/from QString or others if such are required by the use scenario. That would hopefully allow the class to have a broader use throughout Calitko.

According to RFC-3986 there are hierarchical and non-hierarchical URI. A format for each is defined, which would allow generic parsers (without awareness of the specific sheme) could be written:

         foo://example.com:8042/over/there?name=ferret#nose
         _/   ______________/_________/ _________/ __/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         /  /                        
         urn:example:animal:ferret:nose


My suggestions would be then to have QByteArray fields scheme, authority, path, query, fragment (with setters and getters). The fields userinfo, host and port (subfields of authority) could be added as well.

QUrl supports international domain names (performs the necessary encodings) but that would be outside the scope of class Uri. Maybe Scheme classes could be used to perform the necessary conversions.

Ideas and suggestions are welcome!

Regards,

Peter

Would you like to post a relpy?


This post starts a thread.
No follow-ups yet.