dlang-requests icon indicating copy to clipboard operation
dlang-requests copied to clipboard

external URI parser

Open ikod opened this issue 8 years ago • 12 comments

Giles Bathgate:

This uri abstraction might be a useful sub component of these http libs: https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/uri.d

ikod avatar May 16 '16 12:05 ikod

@ikod I am putting together a testsuite to test various uri backends: https://github.com/GilesBathgate/uri This should give an idea of performance and robustness.

GilesBathgate avatar May 17 '16 07:05 GilesBathgate

I commited ftp code and unittests, will look on uri lib.

ikod avatar May 17 '16 11:05 ikod

What is the best practice for using modules from alpha libraries? Is it ok if I just place it in my source tree?

ikod avatar May 17 '16 17:05 ikod

ping @wilzbach

GilesBathgate avatar May 17 '16 17:05 GilesBathgate

Why not? (but I don't have detailed experience in best practices for this either) Anyways as long as you haven't reached 1.0, you shouldn't worry about this too much.

wilzbach avatar May 17 '16 17:05 wilzbach

@ikod I would like to say that I am not getting good results from the alphaPhobos library, I am trying vibe.d implementation instead.

GilesBathgate avatar May 17 '16 17:05 GilesBathgate

Is it ok if I just place it in my source tree?

To clarify you mean using git submodules? You can also tell dub to use master of its already released there..

wilzbach avatar May 17 '16 17:05 wilzbach

To clarify you mean using git submodules?

Never tried git submodules, but they should work, thanks for idea.

ikod avatar May 17 '16 19:05 ikod

@ikod Here are some initial results of the various Uri parsing libraries. (A reference implementation was made by wrapping the c library liburiparser)

  • liburiparser 54 ms, 970 μs
  • vibe.d (url.d) 194 ms, 850 μs
  • arsd (http2.d) 1249 ms, 602 μs
  • alphaPhobos (uri.d) core.exception.InvalidMemoryOperationError@/home/giles/ldc/runtime/druntime/src/core/exception.d(679): Invalid memory operation

The test was just a simple one run in a loop 10,000 times

        auto u = new Uri("http://user:pass@host:99/foo/bar?baz#qux");
        assert(u.scheme == "http");
        assert(u.username == "user");
        assert(u.password == "pass");
        assert(u.host == "host");
        assert(u.port == 99);
        assert(u.absolutePath == "/foo/bar");
        assert(u.query == "baz");
        assert(u.fragment == "qux");

GilesBathgate avatar May 17 '16 22:05 GilesBathgate

@ikod Here is another test run:

  • liburiparser 89 ms, 341 μs
  • vibe.d (url.d) 273 ms, 522 μs
  • arsd (http2.d with ctRegex) 429 ms, 416 μs
  • uriparse.d 53 ms, 104 μs

uriparse.d is my attempt at creating a new uriparsing library. It will probably only currently parse the most basic of urls, but its still the fastest ;)

GilesBathgate avatar May 21 '16 16:05 GilesBathgate

@GilesBathgate Finally pushed http and ftp requests joined under single structure. One of the goal was not to break API and give user unified interface for http and ftp, which at the same time can give different details on responses. I'm not happy with proposed code, and will try to improve it. Anyway if you have any final results on URI tests, I will try to incorporate another URI parser. Thanks.

ikod avatar May 24 '16 02:05 ikod

@ikod, @GilesBathgate What about urld ?

anton-dutov avatar Jan 22 '17 01:01 anton-dutov