Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Module programming and using IDE internal web server. Must restart the IDE.
Tue, Aug 4 2015 3:33 AMPermanent Link

Michael Dreher

I' am programming a module DLL for custom datasets and an EWB browser application (V2.00) using the module.
The Module is developed in Delphi XE2, die IDE is configured to use this custom DLL. Both (Delphi, EWB IDE) are
running at the same time.

I make changes in the module, switch the internal webserver in the IDE off (so the DLL is not in use an can be created), compile the module (the DLL is recreated), switch the internal webserver in the IDE on, compile and start the browser application in the IDE, and see responses of the "old module" in my debug window, that does not exist anymore. Only when I close the IDE, start a new IDE and run the application, I see the last changed from the module.

It seems, stopping and restarting the webserver in der IDE does not fully unload the custom module. Is
this behavior intentional? I may suggest to reload custom modules when the webserver in the IDE starts.

Michael Dreher
Tue, Aug 4 2015 8:52 AMPermanent Link

Michael Dreher

I'll add the following I don't understand on this:

The request to the module is done by the TServerRequest.

I start the application in the IDE. Then I press the "Stop the selected webserver" button and read in the message window:
  -   [internal web server] stopped listening at port 80

Now I press a button on the still visible TForm in the IDE, sending a request , and I get answer from the module. Who is answering? I stopped the internal web server before.

Michael Dreher
Tue, Aug 4 2015 9:01 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< I make changes in the module, switch the internal webserver in the IDE off (so the DLL is not in use an can be created), compile the module (the DLL is recreated), switch the internal webserver in the IDE on, compile and start the browser application in the IDE, and see responses of the "old module" in my debug window, that does not exist anymore. Only when I close the IDE, start a new IDE and run the application, I see the last changed from the module. >>

I just tested this under the debugger, and the modules are definitely being unloaded/reloaded on server stop/start.  Also, if they weren't, then you wouldn't be able to overwrite the module DLL.

Are you sure that your Delphi project output directory is set to create the module DLL in the same directory where the module is being loaded for the EWB IDE ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Aug 4 2015 10:36 AMPermanent Link

Michael Dreher

Tim Young [Elevate Software] wrote:

   //  I just tested this under the debugger, and the modules are definitely
   //  being unloaded/reloaded on server stop/start.  Also, if they weren't, then you wouldn't be
   //  able to overwrite the module DLL.
   //  
   //  Are you sure that your Delphi project output directory is set to create the module DLL
   //  in the same directory where the module is being loaded for the EWB IDE ?

I've checked this. The Delphi output directory is the same the IDE points to, for loading the custom module. The DLL can be linked in Delphi while the IDE webserver is on. I added an additional timestamp response line in the module and I can see this in the IDE, after restarting.

Now I notice, that this timestamp in the in the IDE remains the same as on the first request. When the TServerRequest is executed again, the same timestamp is tracked in the OnComplete handler. I stop the webserver in the IDE (see my 2'nd post), and the OnComplete handler is triggered again in the IDE with Statuscode 200. May be my code is not correct. The condensed form is (more complete and messy in the attachment):

// send TSeverRequest
procedure TfmMain.btSearchProdOrderClick(Sender: TObject);
var
 prodOrderNo : string;
 posNo       : integer;
 str         : string;

begin
 srSearchProdOrder.URL:='/modules/ewbmodule'; // deligation to our module

 str         := edProdOrderNo.Text;            // 745834001
 prodOrderNo := Copy(str, 1, Length(str) - 3); // 745834
 posNo       := StrToInt(Copy(str, Length(str) - 2, 3));

 srSearchProdOrder.Params.Clear;
 srSearchProdOrder.Params.Add('method=ft_request');         // TODO: Konstantn verwenden
 srSearchProdOrder.Params.Add('query_type=prodorder_info');
 srSearchProdOrder.Params.Add('query_no=0');
 srSearchProdOrder.Params.Add('prod_order_no=' + prodOrderNo);
 srSearchProdOrder.Params.Add('prod_order_pos_no=' + IntToStr(posNo));
 srSearchProdOrder.Params.Add('sernos=' + StringsAsText(mmSerNos.Lines));
 srSearchProdOrder.ResponseContent.LineSeparator:=#10;

 srSearchProdOrder.Execute;
end;

//OnComplete handler
procedure TfmMain.srSearchProdOrderComplete(Request: TServerRequest);
var
 strError : string;

begin
 LogOutput('STATUS CODE: ' + IntToStr(Request.StatusCode));
 // print out respondse header and content...
 memo.Lines.Clear;
 memo.Lines.Add('[STATUS CODE: ' + IntToStr(Request.StatusCode));

 memo.Lines.Add('[response headers]');
 memo.Lines.Add(Request.ResponseHeaders.Text);
 memo.Lines.Add('[response content]');
 memo.Lines.Add(Request.ResponseContent.Text);
end;

Michael Dreher



Attachments: handlers.txt
Wed, Aug 5 2015 4:06 AMPermanent Link

Michael Dreher

I'll redefine and summarize the probem I observe:
-------------------------------
1) In the browser application started in the (new started) IDE (using a custom module), the responde header in TServerRequest in the OnComplete hander after the first request is

(a)
Date: Wed, 5 Aug 2015 06:59:26 GMT
From:
Server: Internal Web Server
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Content-Length: 302

with status code 200 (and with the expected response contents, not listeed here), For all following (same) TServerRequest's the header is

(b)
From:
Content-Type: text/html; charset=utf-8
Content-Length: 302

with status code 200 and the same response contents as in the first request. Also when I restart the application in the IDE (and possible stop/restart the internal webserver) the response (b) remains with status 200 and the response context.
-------------------------------
2) Starting the same emitted HTML/JS in Firefox by calling URL localhost, while the IDE is closed (or it's webserver stoped), and XE2 runs the module with ewbsrvr.exe als the host parameter, I always get responses like (a) with actual timestamps on additional requests (I can debug the module requests in Delphi).
-------------------------------
3) Also, loading the Page with firefox via localhost as described in 2), then stop Delphi (closing the module and ewbsrvr.exe), starting the internal webserver in the IDE (changing the webserver in between), all following responses in firefox are (a)-like with fresh timestamps, while at the same time the response of the application started in the IDE remains (b).

Now I stop the webserver in the IDE. The next TServerRequest in the firefox is empty with status code 0 as expected, while in the IDE the response is (b) with status code 200.
---------------------------------

Perhaps I've made a terrible configuration error. To make progress (loosing to much time) in my project I now use the method 2). Thanks for now.

M. Dreher
Wed, Aug 5 2015 5:32 AMPermanent Link

Michael Dreher

Hi,

At last I resolved the problem. It's an internet explore cache option:
  - iexplore  / internet options / browser history / settings / temporary internet files / search new website versions
was set to "automatic".

And the behavior of iexplore (and the EWB IDE using the IE) is: the first TServerRequest is send to the webserver. If the request parameter do not change, all following responses in the IE seem to be provided by an internal cache. In our database driven project this is not desirable; database state may be changed at later time for the same parameters.

I set the cache option to "[search] every request on the website" and iexplore and the IDE get fresh answers from the module every request. That's importand to know, when the application later is shipped to our cutomer.

Michael Dreher
Wed, Aug 5 2015 6:36 AMPermanent Link

Walter Matte

Tactical Business Corporation


I wrote my own webserver and send back a "Cache-Control" parameter in the Header to ensure pages are not stored - for this very reason - they don't get pulled from cache.

I have not used Tim's server - can you add Header parameters when responding to EWB requests - this may solve the issue and then you don't need to tell your users they must tweak IE settings.


Cache-Control: no-cache, no-store, must-revalidate, post-check=0, pre-check=0


Walter
Wed, Aug 5 2015 10:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< And the behavior of iexplore (and the EWB IDE using the IE) is: the first TServerRequest is send to the webserver. If the request parameter do not change, all following responses in the IE seem to be provided by an internal cache. In our database driven project this is not desirable; database state may be changed at later time for the same parameters. >>

As Walter indicates, what you want is this:

procedure TEWBModule1.EWBModuleExecute(Request: TEWBServerRequest);
begin
  // Tell browser not to cache response
  Request.ResponseHeaders.Add('Cache-Control: no-cache');
  case Request.RequestMethod of
....
end;

That will prevent IE from caching your module responses, and you can use it selectively, depending upon your needs.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Aug 6 2015 3:51 AMPermanent Link

Michael Dreher

Walter, Tim,

thanks for the concrete hints. I added the no-cache option in the TModule::OnExecute, and control this by a no-cache:boolean server request parameter. Works beautifully.

Michael Dreher
Image