Просмотр исходного кода

Send \r\n in html instead of only \n

Kolja Strohm 5 лет назад
Родитель
Сommit
a2f09fbb6d
2 измененных файлов с 10 добавлено и 9 удалено
  1. 5 5
      Network/HttpRequest.cpp
  2. 5 4
      Network/WebSocket.cpp

+ 5 - 5
Network/HttpRequest.cpp

@@ -20,16 +20,16 @@ Answer *PostRequest::execute() const
 {
     Text message = "POST ";
     message += path;
-    message += " HTTP/1.1\n";
+    message += " HTTP/1.1\r\n";
     message += "Host: ";
     message += host;
-    message += "\nContent-Type: ";
+    message += "\r\nContent-Type: ";
     message += contentType;
-    message += "\nContent-Length: ";
+    message += "\r\nContent-Length: ";
     message += data.getLength();
-    message += "\n\n";
+    message += "\r\n\r\n";
     message += data;
-    message += "\n";
+    message += "\r\n";
     Klient httpK;
     if( !httpK.verbinde( port, host ) )
         return 0;

+ 5 - 4
Network/WebSocket.cpp

@@ -62,11 +62,11 @@ __declspec( dllexport ) bool WebSocketClient::connect()
     {
         Text message = "GET ";
         message += path;
-        message += " HTTP/1.1\n";
+        message += " HTTP/1.1\r\n";
         message += "Host: ";
         message += host;
-        message += "\nUpgrade: websocket\n";
-        message += "Connection: Upgrade\n";
+        message += "\r\nUpgrade: websocket\r\n";
+        message += "Connection: Upgrade\r\n";
         char *key = new char[ 25 ];
         key[ 24 ] = 0;
         key[ 23 ] = '=';
@@ -76,7 +76,7 @@ __declspec( dllexport ) bool WebSocketClient::connect()
         message += "Sec-WebSocket-Key: ";
         message += key;
         delete[] key;
-        message += "\nSec-WebSocket-Version: 13\n\n";
+        message += "\r\nSec-WebSocket-Version: 13\r\n\r\n";
         klient = new Klient();
         if( !klient->verbinde( port, host ) )
         {
@@ -357,6 +357,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
                 {
                     if( nextClose )
                     {
+                        c.unlock();
                         c2.lock();
                         klient->trenne();
                         klient = klient->release();