May 14, 2023

On Sunday, 14 May 2023 at 11:32:46 UTC, Vladimir Panteleev wrote:

>

On Sunday, 14 May 2023 at 10:56:29 UTC, Andrea Fontana wrote:

>

Hmm I don't think you can use utf-8 encoding in your request. I think everything must be encoded as old US-ASCII.

Oh also, I noticed that bad UTF-8 in URLs is rejected. Unless you're decoding UTF for the purpose of validating that further logic doesn't have to deal with bad UTF-8, that also indicates a potential inefficiency. Web servers don't need to do any UTF-8 decoding, but it's very easy to do it accidentally in D.

I'm doing some validations on data because that data is parsed and stored for serverino's users :)

The UTF problem is actually a catched UTFException thrown by urlencode/decode of std library.

And I'm trying to keep it a bit safe for user, let's say. I don't think any browser will send an invalid utf sequence as url, it sounds like you're trying to make some attack and I give you back a 400 bad request error.

It's not the only check I'm doing anyway.

I'm trying to understand what's wrong with mojibake, still not sure it is a bug :)

Andrea

May 14, 2023

On Sunday, 14 May 2023 at 13:53:49 UTC, Andrea Fontana wrote:

>

The UTF problem is actually a catched UTFException thrown by urlencode/decode of std library.

This doesn't throw for me:

void main()
{
	import std.uri;
	decode("\xFF");
	encode("\xFF");
}

But... looking at the implementation, it does have a baked-in UTF-8 decoder, which is a little ridiculous. decode actually decodes percent-encoded UTF-8, and then encodes it back, but makes no attempt to validate the non-encoded parts of the string. The module is pretty old though, so maybe it predates the facilities in std.utf.

May 14, 2023

On Saturday, 13 May 2023 at 09:03:22 UTC, Andrea Fontana wrote:

>

Hi everyone, as I had already announced in the discord channel...

Hi Andrea,

this question may be not completely related, but hopefully you can answer. I can see a worker concept and each worker is a completely separate application and doesn't share context with other workers.

For example I have a __gshared state with some data which is being updated by separate thread. So I need all workers (threads) be able to access that state without recreating it multiple times.

Is it possible to achieve it without introducing a separate cache or database, just inside single app and Serverino serving data requests through multiple threads?

May 14, 2023

On Sunday, 14 May 2023 at 15:19:24 UTC, psyscout wrote:

>

On Saturday, 13 May 2023 at 09:03:22 UTC, Andrea Fontana wrote:

>

Hi everyone, as I had already announced in the discord channel...

Hi Andrea,

this question may be not completely related, but hopefully you can answer. I can see a worker concept and each worker is a completely separate application and doesn't share context with other workers.

For example I have a __gshared state with some data which is being updated by separate thread. So I need all workers (threads) be able to access that state without recreating it multiple times.

Is it possible to achieve it without introducing a separate cache or database, just inside single app and Serverino serving data requests through multiple threads?

No: workers are not separated threads, but isolated processes.
You should consider that workers' count is dynamic; they can be created and killed if required.

You can still use some ipc (sockets, pipes) etc but probably a db it's easier to manage.

Andrea

May 14, 2023

On Sunday, 14 May 2023 at 14:57:07 UTC, Vladimir Panteleev wrote:

>

On Sunday, 14 May 2023 at 13:53:49 UTC, Andrea Fontana wrote:

>

The UTF problem is actually a catched UTFException thrown by urlencode/decode of std library.

This doesn't throw for me:

void main()
{
	import std.uri;
	decode("\xFF");
	encode("\xFF");
}

But... looking at the implementation, it does have a baked-in UTF-8 decoder, which is a little ridiculous. decode actually decodes percent-encoded UTF-8, and then encodes it back, but makes no attempt to validate the non-encoded parts of the string. The module is pretty old though, so maybe it predates the facilities in std.utf.

You mean %ff not \xff!

Andrea

1 2
Next ›   Last »