Преглед изворни кода

webserver: spurious newline after data confuses curl

Webserver wrongly sends an additional newline after the data which
causes curl to believe that the next request on this socket has no
header data and so includes all headers in the data output.

Git-Dch: Ignore
David Kalnischkies пре 12 година
родитељ
комит
93a99dac87
1 измењених фајлова са 9 додато и 9 уклоњено
  1. 9 9
      test/interactive-helper/aptwebserver.cc

+ 9 - 9
test/interactive-helper/aptwebserver.cc

@@ -137,21 +137,21 @@ bool sendFile(int const client, FileFd &data)				/*{{{*/
    {
    {
       if (actual == 0)
       if (actual == 0)
 	 break;
 	 break;
-      if (Success == true)
-	 Success &= FileFd::Write(client, buffer, actual);
+      Success &= FileFd::Write(client, buffer, actual);
    }
    }
-   if (Success == true)
-      Success &= FileFd::Write(client, "\r\n", 2);
+   if (Success == false)
+      std::cerr << "SENDFILE: READ/WRITE ERROR to " << client << std::endl;
    return Success;
    return Success;
 }
 }
 									/*}}}*/
 									/*}}}*/
 bool sendData(int const client, std::string const &data)		/*{{{*/
 bool sendData(int const client, std::string const &data)		/*{{{*/
 {
 {
-   bool Success = true;
-   Success &= FileFd::Write(client, data.c_str(), data.size());
-   if (Success == true)
-      Success &= FileFd::Write(client, "\r\n", 2);
-   return Success;
+   if (FileFd::Write(client, data.c_str(), data.size()) == false)
+   {
+      std::cerr << "SENDDATA: WRITE ERROR to " << client << std::endl;
+      return false;
+   }
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/
 void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/