The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,570 other followers

Archive for the ‘Software Development’ Category

web services – Accessing the original TWebRequest object in a Delphi SOAP Server – Stack Overflow

Posted by jpluimers on 2019/05/22

Thanks Ondrej Kelle for answering this:

uses
  System.SysUtils,
  Web.HTTPApp,
  Soap.WebBrokerSOAP;

function TTest.CallMe: string;
var
  WebDispatcher: IWebDispatcherAccess;
begin
  Result := '';
  if Supports(GetSOAPWebModule, IWebDispatcherAccess, WebDispatcher) then
    Result := Format('You are calling me from: %s', [WebDispatcher.Request.RemoteIP]);
end;

Source: [WayBack] web services – Accessing the original TWebRequest object in a Delphi SOAP Server – Stack Overflow

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

It was all Greek to me: Iota · golang/go

Posted by jpluimers on 2019/05/21

Context is king!

Being Dutch, my association with iota was the phrase “Ik snap er geen iota van” (English: “It’s all Greek to me”), basically indicating iota is extremely small, similar to [WayBack] Iota | Definition of Iota by Merriam-Webster:

1an infinitesimal amount jot  (did not show an iota of interest)
2the 9th letter of the Greek alphabet — see alphabet table

But the first time, I saw iota used in golang, I actually confused it with [WayBack] itoa – C++ Reference, because I am more than slightly wordblind.

So code like this was all Greek to me at first, not understanding the conversion from integer to ASCII**, and slightly later, not understanding iota to be extremely small either. Heck, its usage indicates it is small from infinitesimal:

const (
    _           = iota // ignore first value by assigning to blank identifier
    KB ByteSize = 1 << (10 * iota)
    MB
    GB
    TB
    PB
    EB
    ZB
    YB
)

So it took me a bit of thought to realise that it actually had to mean something completely different, so I found

It makes me wonder why they named it like this.

Slightly related:

–jeroen

Read the rest of this entry »

Posted in C++, Development, Go (golang), Software Development | Leave a Comment »

draft-ietf-appsawg-http-forwarded-10 – Forwarded HTTP Extension (X-Forwarded-For, X-Forwarded-By, and X-Forwarded-Proto)

Posted by jpluimers on 2019/05/21

Since many HTTP stacks do not have fields for this so it’s hard to get the originating IP address:

It is about these HTTP header fields with and without X- prefix:

  • Forwarded
  • X-Forwarded-For
  • X-Forwarded-By
  • X-Forwarded-Proto

Note that widely used tools like HAProxy do not always fully adhere to the “standard”…

Via:

–jeroen

Posted in Communications Development, Development, HTTP, Internet protocol suite, Software Development, TCP | Leave a Comment »

Delphi XE8 introduced the dependency directive, but it’s not for Windows

Posted by jpluimers on 2019/05/21

Interesting thread that shows Delphi XE8 introduced a dependency directive: [WayBack] Just curious, in which version was the dependency directive introduced? As in procedure X; external ‘somelib’ dependecy ‘otherlib’; S… – Johan Bontes – Google+

It’s documented as of XE8: [WayBack] Procedures and Functions (Delphi) – RAD Studio: Specifying Dependencies of the Library

The earliest use I could find is in XE4 source C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\source\IBX\IBIntf.pas

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

The Initialization-Block of a unit that is part of a package. Is it run as part of DLLMain?

Posted by jpluimers on 2019/05/16

The interesting question a while back [WayBack] The Initialization-Block of a unit that is part of a package. Is it run as part of DLLMain? – Alexander Benikowski – Google+ has a simple TL;DR answer: “it depends” on the actual usage of those units.

Way more elaborate, as I dislike language stuff that you need to track down by trial and error what is actually used:

Well, seems so(in our case). Rootcall which triggers the initialization is:
ntdll.ldrLoadDLL
I did not mention, that the BPL is used by a DLL(DLL links against package) which means the package is loaded/initialized by the Os when the DLLMain runs. Odd combination but that seems to be the culprit here.

David Heffernan
Yes, it is triggered from DllMain. And yes, this has massive consequences for what can and cannot be done in initialization sections.

Alexander Benikowski
+David Heffernan in my case. When a packages unit is already initialized by being used from an Exe(which links to the Package), it is not from within a DLLMain.
In my case, both the Application and the dll it loads, both link to the same package. But the unit in question is unused until the DLL is loaded.

Uwe Raabe
The docs for InitializePackage say it calls the initialization parts of all contained units in the package – not only the used ones.

David Heffernan
+Alexander Benikowski​ In that scenario we have load time linking and I guess the package framework handles it differently.

David Millington
Related: don’t forget that class constructors and destructors effectively run in the initialization and finalization sections too. Restrictions or side effects apply there too. docwiki.embarcadero.com – Methods (Delphi) – RAD Studio

Stefan Glienke
+Uwe Raabe Which is not being done when you use it as runtime package. Only initialization sections from unit being used are being run. This caused us several problems in the past where 2 modules (A being the host application exe and B being some DLL that gets loaded at a later point via LoadLibrary) were using a runtime package but only B used a particular unit from the package which caused the initialization code for that unit being executed when B was loaded and hence being executed in the context of the dllmain of B.

The usual solution is then to put those units into some dummy unit forcing the initialization of that unit to be run in A.

Another solution according to your statement could be to call InitializePackage on all the used runtime packages – and there the question is: couldn’t the RTL do that somehow?

+Stefan Glienke I am not sure if that is desirable when done unconditionally. Even when compiled with packages I wouldn’t expect units to be initialized which aren’t actually used. That would perhaps change the behavior of the application depending on whether it is compile with runtime packages or without.
The case is different with dynamic loaded packages. The units in there are obviously not directly used in the first place. As no one can know which units of such a package are used or not, initializing all of them seems like a viable decision.
Of course there will be situations where your proposed behavior might come in handy, but I doubt that this will be a fit for all.

Source: The Initialization-Block of a unit that is part of a package. Is it run as pa…

Related:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: