omnibrain 15 Posted November 20, 2023 I added a PUT handler to my API (so far I worked with POST, for my new API iteration I'm finally getting to implementing PUT), but it does not get dispatched. HttpAppSrv1.AddPutHandler('/'+porticoversion+'/object/*',Tlisaapiportico); // Person anlegen PUT /object/{oid}/person Tlisaapiportico is implementing TUrlHandler. I debugged, and it looks like the handler get's correctly added to the FPutHandler, but PutDispatchVirtualDocument gets never reached. Further debugging (and comparison with POST) lead me to TriggerPutDocument. When I comment out the "Flags-Check" it works. procedure THttpAppSrv.TriggerPutDocument( { V8.67 } Sender : TObject; var Flags : THttpGetFlag); begin //OutputDebugString(PChar('HTTP_PUT ' + (Sender as THttpAppSrvConnection).Path)); inherited TriggerPutDocument(Sender, Flags); { if Flags in [hgWillSendMySelf, hg404, hg403, hg401] then Exit ; } // Handle all virtual documents. Returns TRUE if document handled. if PutDispatchVirtualDocument(Sender as THttpAppSrvConnection, Flags) then Exit; // Reject anything else Flags := hg404; end; In TriggerDeleteDocument is a similar check. I did not test it yet, but I imagine I'm going to run into the same problem. Of course I don't know if the real problem is, that the flag get's set wrong somewhere higher in the call stack, or if the inherited call should do something instead. Share this post Link to post
Angus Robertson 574 Posted November 20, 2023 Thanks, that will explain why a PUT test upload failed recently, it was still on my list to test, fix will be in SVN this week. Angus Share this post Link to post
omnibrain 15 Posted November 20, 2023 When further testing I discovered an additional problem: My PUT obviously happens with data. But in my dispatched handler no data arrives. When debugging I noticed, that the handler get's dispatched before the data is received. An additional ConnectionDataAvailable where FState is hcPostedData happens after the dispatch. I meant to test it properly all earlier, after you implemented it for me, but other projects happened and my workaround with POST worked. Share this post Link to post
Angus Robertson 574 Posted November 20, 2023 I will test PUT finally works this week, but not for a couple of days. Angus 1 Share this post Link to post
Angus Robertson 574 Posted November 22, 2023 The main problem with the PUT handler in the application server was a complete lack of content upload handling, it was just ignored, now fixed, will be in SVN today. Angus 1 Share this post Link to post
omnibrain 15 Posted December 5, 2023 (edited) I downloaded and installed the latest daily snapshot from https://wiki.overbyte.eu/arch/icsv9w.zip but still can't get PUT to work. I still run into the "Flags"-check from my original post. Am I missing something else? The Flags in question contains hg404. The path I call the PUT with Postman is http://192.168.247.109:16008/v2/object/1004/person My other GET and POST Handlers work like they used to. Edit: If I comment out the Flags-Check like I did in my original post it now works. So your fix handling the uploads worked. Edited December 5, 2023 by omnibrain Share this post Link to post
Angus Robertson 574 Posted December 5, 2023 Thanks, those checks are not in the POST handler and I thought I'd removed them since my PUT tests all worked, but now gone. SVN may be a few days. Angus 1 Share this post Link to post