Skip to content

Commit f408405

Browse files
committed
pseudo-user for interactive Perl scripts
1 parent 46b32bb commit f408405

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ If PEB is going to be compiled for end users and interaction with the Perl debug
142142
**interactive scripts**, **noninteractive scripts** and **AJAX scripts**.
143143
There is no timeout for all Perl scripts executed by PEB.
144144
* **Interactive Perl scripts:**
145-
Interactive Perl scripts have their own event loop waiting constantly for new data arriving on STDIN and that's why they have bidirectional connection with PEB. There can be only one interactive script per browser window. Interactive scripts must be started with the special query string items ```type=interactive```, ```target```, ```close_command``` and ```close_confirmation```.
145+
Interactive Perl scripts have their own event loop waiting constantly for new data arriving on STDIN and that's why they have bidirectional connection with PEB. There can be only one interactive script per browser window. Interactive scripts must be started with the special pseudo-user ```interactive``` and with the query string items ```target```, ```close_command``` and ```close_confirmation```.
146146

147-
The query string item ```type=interactive``` is the token used by PEB to distinguish between interactive and all other scripts.
147+
The pseudo-user ```interactive``` is the token used by PEB to distinguish between interactive and all other scripts.
148148

149149
The ```target``` query string item should point to a valid HTML DOM element or to a valid JavaScript function. Every piece of script output is inserted immediately into the target DOM element of the calling page or passed to the specified JavaScript function as its first and only function argument. The calling page must not be reloaded during the script execution or no script output will be inserted.
150150

@@ -156,12 +156,11 @@ If PEB is going to be compiled for end users and interaction with the Perl debug
156156
document.addEventListener("DOMContentLoaded", function(event) {
157157
var request = new XMLHttpRequest();
158158
var parameters = {
159-
type: "interactive",
160159
target: "output",
161160
close_command: "_close_",
162161
close_confirmation: "_closed_"
163162
}
164-
request.open('GET', 'perl/interactive-script.pl' + formatParameters(parameters), true);
163+
request.open('GET', 'http://interactive@local-pseudodomain/perl/interactive-script.pl' + formatParameters(parameters), true);
165164
request.send();
166165
});
167166

resources/app/interactive-script.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@
4848
document.addEventListener("DOMContentLoaded", function(event) {
4949
var request = new XMLHttpRequest();
5050
var parameters = {
51-
type: "interactive",
5251
target: "output",
5352
close_command: "_close_",
5453
close_confirmation: "_closed_"
5554
}
56-
request.open('GET', 'perl/interactive-script.pl' + formatParameters(parameters), true);
55+
request.open('GET', 'http://interactive@local-pseudodomain/perl/interactive-script.pl' + formatParameters(parameters), true);
5756
request.send();
5857
});
5958

src/peb.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class QAccessManager : public QNetworkAccessManager
330330
// local files and non-AJAX scripts:
331331
// ==============================
332332
if (operation == GetOperation and
333-
request.url().authority() == PSEUDO_DOMAIN and
333+
request.url().host() == PSEUDO_DOMAIN and
334334
(request.url().userName() != "ajax") and
335335
(!request.url().path().contains(".function"))) {
336336

@@ -458,7 +458,7 @@ class QAccessManager : public QNetworkAccessManager
458458
// non-AJAX scripts:
459459
// ==============================
460460
if (operation == PostOperation and
461-
request.url().authority() == PSEUDO_DOMAIN and
461+
request.url().host() == PSEUDO_DOMAIN and
462462
(request.url().userName() != "ajax")) {
463463

464464
if (outgoingData) {
@@ -486,8 +486,7 @@ class QAccessManager : public QNetworkAccessManager
486486
return reply;
487487
}
488488

489-
qInfo() << "Link requested:"
490-
<< request.url().toString();
489+
qInfo() << "Link requested:" << request.url().toString();
491490

492491
return QNetworkAccessManager::createRequest
493492
(QNetworkAccessManager::GetOperation,
@@ -541,10 +540,9 @@ public slots:
541540
url.path());
542541

543542
QUrlQuery scriptQuery(url);
544-
QString scriptType = scriptQuery.queryItemValue("type");
545543

546544
// Start the interactive script:
547-
if (scriptType == "interactive" and
545+
if (url.userName() == "interactive" and
548546
(!interactiveScriptHandler.isOpen())) {
549547

550548
interactiveScriptFullFilePath = scriptFullFilePath;

0 commit comments

Comments
 (0)