0> In article <krakonos+md-20150501.103253.16671.mus...@krakonos.org>,
0> Ladislav Laska <URL:mailto:la...@kam.mff.cuni.cz> ("Ladislav") wrote:

Ladislav> Thanks! Did you test issue 8?  I've fixed some stuff that
Ladislav> could be related, but have not yet tested if it really is
Ladislav> fixed.

It's now Working for Me (TM).  Last week, every upload would leave the
changes visible in the Undo dock, and subsequent uploads would fail with
conflicts unless I remembered to undo everything (much faster in
wireframe mode!) and re-download anything I might change again.  A pain
in the proverbial!  That hasn't happened to me since updating.


>> P.P.S. I have a small improvement to the HTTP server which stops
>> Iceweasel opening blank tabs when I mouse-2 on "edit" links.  I've
>> not yet got to grips with GitHub - is it okay to post a small diff
>> here for inclusion?

Ladislav> Sure, every patch counts!

Okay, appended.  It changes the success response to 204 No Data, and it
also adds a bit of robustness in the face of invalid requests.

diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index d2cf337..4c2216f 100755
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -1074,20 +1074,29 @@ void MainWindow::readLocalConnection()
     if ( socket->canReadLine() ) {
         QString ln = socket->readLine();
         QStringList tokens = ln.split( QRegExp("[ \r\n][ \r\n]*"), QString::SkipEmptyParts );
-        if ( tokens[0] == "GET" ) {
+        if ( tokens.size() < 2 || tokens[0] != "GET" ) {
+            static const QString message = "Inappropriate method for server\r\n";
             QTextStream resultStream(socket);
-            resultStream << "HTTP/1.1 200 OK\r\n";
-            resultStream << "Date: " << QDateTime::currentDateTime().toString(Qt::TextDate);
+            resultStream << "HTTP/1.1 405 Method Not Allowed \r\n";
+            resultStream << "Date: " << QDateTime::currentDateTime().toString(Qt::TextDate) << "\r\n";
             resultStream << "Server: Merkaartor RemoteControl\r\n";
             resultStream << "Content-type: text/plain\r\n";
             resultStream << "Access-Control-Allow-Origin: *\r\n";
-            resultStream << "Content-length: 4\r\n\r\n";
-            resultStream << "OK\r\n";
+            resultStream << "Content-length: " << message.length() << "\r\n\r\n";
+            resultStream << message;
             socket->disconnectFromHost();
-
-            QUrl u = QUrl(tokens[1]);
-            loadUrl(u);
+            return;
         }
+        {
+            QTextStream resultStream(socket);
+            resultStream << "HTTP/1.1 204 No data\r\n";
+            resultStream << "Date: " << QDateTime::currentDateTime().toString(Qt::TextDate) << "\r\n";
+            resultStream << "Server: Merkaartor RemoteControl\r\n";
+            resultStream << "Access-Control-Allow-Origin: *\r\nr\n";
+        }
+
+        loadUrl(QUrl(tokens[1], QUrl::StrictMode));
+        socket->disconnectFromHost();
     }
 }
 
_______________________________________________
Merkaartor mailing list
Merkaartor@openstreetmap.org
https://lists.openstreetmap.org/listinfo/merkaartor

Reply via email to