ToddFrankson 10 Posted Friday at 11:33 PM So, I am revisiting an ISAPI dll I wrote some time back.... I have a bunch of actions. In particular I have an /index and a /header action. Header generates a header based on input from which action is called and which "options" the end user has selected prior to the call for the action. Simple stuff.... In D5-D7, this isapi dll could call the header via a get from the Index action (or any other) and everything worked fine (also a footer but we aren't going there yet). Upgrading it to D12.3 If I call the header directly {http://127.0.0.1/script/CC_Web.dll/getheader?cat=6&mob=n) in my browser, it returns the expected header fine Wen called from within an action: procedure TWebModule1.WebModule1indexAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); var myHeader:String; Begin ....... // nmHttp is a visual component TIDHttp; MyHeader:=nmHttp1.Get('http://127.0.0.1/script/CC_Web.dll/getheader?cat=6&mob='+Mobile); Response.Content:=MyHeader; Response.SendResponse; Handled:=true; End; My header is blank. Occasionally I get an Http 1.1 5 error. Is there something new that ISAPI can not call actions within the same ISAPAI from one action to another? If I type this in the browser: http://127.0.0.1/script/CC_Web.dll/getheader?cat=6&mob=n, the header renders perfectly. Share this post Link to post
corneliusdavid 249 Posted Monday at 10:35 PM Is your ISAPI DLL multi-threaded? Here's what I think is happening: the web server is handling an action (indexAction) and before it's finished and can return the result, you're trying to call another action on the same server by making a Get request out to the internet and back to the localhost. But since the server is still trying to get a response to the first request and if your ISAPI server is single-threaded, it can't process the second request until the first request is finished; therefore, it's probably timing out and returning blank. Instead of making another HTTP request, why not just call the desired action directly? And by "call the action directly" I making make a procedural call within your code--not an external HTTP request which goes out to the internet and back to the current server. Why would you do that, anyway? Now, you said it worked when built under D5/D7? Perhaps that was an earlier version of Indy that had a bug or there was some other setting different. Or I'm way off in my understanding of what's really going on. Share this post Link to post
ToddFrankson 10 Posted 15 hours ago 16 hours ago, corneliusdavid said: Is your ISAPI DLL multi-threaded? Here's what I think is happening: the web server is handling an action (indexAction) and before it's finished and can return the result, you're trying to call another action on the same server by making a Get request out to the internet and back to the localhost. But since the server is still trying to get a response to the first request and if your ISAPI server is single-threaded, it can't process the second request until the first request is finished; therefore, it's probably timing out and returning blank. Instead of making another HTTP request, why not just call the desired action directly? And by "call the action directly" I making make a procedural call within your code--not an external HTTP request which goes out to the internet and back to the current server. Why would you do that, anyway? Now, you said it worked when built under D5/D7? Perhaps that was an earlier version of Indy that had a bug or there was some other setting different. Or I'm way off in my understanding of what's really going on. It is multi-threaded, All Urls are localhost/127.0.0.1. I use the IDHttp to do a get of the action from within another action. Si I have a header and footer action. Based on the values go in, they are created slightly different based on the root action they are called from. I have turned a lot of it into procedural at this point. I think it actually is an IIS issue at this point, but since I can't debug in IIS, and I don't have time to learn a 3rd party Web server, it was just easier to proceduralize (is that even a word) the calls. I just prefer trying to understand reasons, especially from way smarter people, like most of those here. Share this post Link to post
corneliusdavid 249 Posted 8 hours ago 7 hours ago, ToddFrankson said: I use the IDHttp to do a get of the action from within another action I cannot fathom why you would want to do that. Regardless of why it's not working (your original question), calling an HTTP Get to the server from which you're running in seems like such a waste of execution time: it has to package a request string, call out to the internet, figure out the address is local, look for a server listening at that address, then send the request to the server. The server, then, has to parse the request, figure out which action will handle the request, and call the appropriate procedure which then packages a response string, sends it back to the caller which finally returns to your calling procedure. Why not just call the procedure you need directly?? You already know what is supposed to happen, which method you want to handle it and what parameters it needs. Maybe I'm missing something but the more I think about it, the more puzzled I am. 7 hours ago, ToddFrankson said: I have turned a lot of it into procedural at this point. That's probably for the best. 7 hours ago, ToddFrankson said: I think it actually is an IIS issue at this point That may be true--IIS may be just as confused about getting a request from itself as I am about the concept! 7 hours ago, ToddFrankson said: I just prefer trying to understand reasons Me too, but I don't think this one needs to be understood--just avoided! Share this post Link to post