Profile cover photo
Profile photo
Andrea Magni
317 followers -
Coding everyday
Coding everyday

317 followers
About
Posts

Post has attachment
Blog post: Next week is by me at Delphi CE Bootcamp. Details and links in the blog post
https://blog.andreamagni.eu/2018/09/my-week-at-delphi-ce-bootcamp/
HOME
HOME
blog.andreamagni.eu

Post has attachment
I have not so much experience with building DLLs in Delphi. I am facing a problem because one of my customer is really fond of having a DLL implementing some core functionalities and several applications relying on it (and other DLLs).

Now the problem I am facing is that type system seems to be duplicated across the executables and the DLL (I can recall reading something about it but finding a reference seems hard). This means that if I build an instance of type X in the DLL and pass it (as a function's result) to the executable, I won't be able to check if that type is of type X ("MyVar is X" will return false).

// var LInstance: TMyAbstractType;
// var LValue: TValue;

LValue := TValue.From<TMyAbstractType>(LInstance);

if LValue.IsInstanceOf(TMyAbstractType) then
ShowMessage('1 - LValue is TMyAbstractType')
else if LValue.AsObject is TMyAbstractType then
ShowMessage('2 - LValue is TMyAbstractType')
else
ShowMessage('3 - LValue ClassName: ' + LValue.AsObject.QualifiedClassName);

Does anybody have some suggestion to workaround this? Apart from checking ClassName as a string...

I have a complete simple project showing the isse and it is available here: https://www.dropbox.com/s/6fpo9m0cq3m84fb/TypesInDLL.zip?dl=0
Clicking on Button1 will trigger code from DLL, Button2 implements the same thing in the executable (and everything works fine).

Post has attachment

Post has attachment
Blog post: DAPUG and Delphi Code Camp 2018 followup and pictures
https://blog.andreamagni.eu/2018/05/dapug-and-delphi-code-camp-followup-and-pictures/
HOME
HOME
blog.andreamagni.eu

Post has attachment
TFrameStand: added a new demo mimicking Android's Bottom Sheet UI pattern #Delphi #TFrameStand #UI #Android

https://blog.andreamagni.eu/2018/04/tframestand-new-bottomsheet-demo/

Post has attachment

Post has attachment

I have a question:
I am trying to send a multipart/form-data using Indy to an http server (based on Indy itself). I am using this code:

var
LS: TIdMultiPartFormDataStream;
LResponse: TMemoryStream;
begin
LResponse := TMemoryStream.Create;
try
LS := TIdMultiPartFormDataStream.Create;
try
LS.AddFormField('test1', 'value1');
LS.AddFormField('test2', 'value2');

idHttp1.Post('http://localhost:8080/rest/default/helloworld/all', LS, LResponse);

ShowMessage(StreamToString(LResponse));
finally
LS.Free;
end;
finally
LResponse.Free;
end;
end;

The problem is that on the server side I can't read test1 and test2 in ContentFields. I dumped the request and here it is:

PathInfo: /rest/default/helloworld/all
Method: POST
ProtocolVersion: HTTP/1.0
Authorization:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
ContentFields:
CookieFields:
QueryFields:
ContentType: multipart/form-data; boundary=--------010918151232122
ContentEncoding:
ContentLength: 337
ContentVersion:
RemoteAddr: 127.0.0.1
RemoteHost:
RemoteIP: 127.0.0.1

Content: ----------010918151232122
Content-Disposition: form-data; name="test1"
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

value1
----------010918151232122
Content-Disposition: form-data; name="test2"
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

value2
----------010918151232122--

Please note that sending a similar request using curl or PostMan actually works... (I can read test1 and test2 in Request.ContentFields after adding Web.ReqMulti to the uses list).

Anyone has a guess?

PS: I made several attempts (i.e. I forced Indy to send http 1.1 instead of 1.0) and using the TNetHttpRequest/Client components works fine (same server of course):
var
LForm: TMultipartFormData;
LHttpResponse: IHTTPResponse;
begin
LForm := TMultipartFormData.Create();
try
LForm.AddField('test1', 'value1');
LForm.AddField('test2', 'value2');
ShowMessage(StreamToString(LForm.Stream));

LHttpResponse := NetHTTPRequest1.Post(
'http://localhost:8080/rest/default/helloworld/all'
, LForm
);

ShowMessage(LHttpResponse.ContentAsString());
finally
LForm.Free;
end;
end;

Post has shared content
Stack Overflow is currently running their annual developer survey.

This year they actually included Delphi as one of the options. so you don't have to type it under other category.

Regardless of your opinion on usefulness of such surveys, if you have Stack Overflow account, go there, fill it up and make the difference.

If you don't have Stack Overflow account.... well, what are you waiting... make one...
Add a comment...

Post has attachment
News! Introducing MARScmd: a tool for MARS-Curiosity REST library ! It is handy to kickstart your new projects:

https://blog.andreamagni.eu/2018/01/introducing-marscmd-a-tool-for-mars-rest-library/
HOME
HOME
blog.andreamagni.eu
Wait while more posts are being loaded