diff --git a/src/server/ltp_server.cpp b/src/server/ltp_server.cpp index d15e6c29d..d61d04588 100644 --- a/src/server/ltp_server.cpp +++ b/src/server/ltp_server.cpp @@ -107,11 +107,17 @@ static int Service(struct mg_connection *conn) { string strSentence = sentence; // validation check - if (strlen(sentence) == 0 || !isclear(strSentence)) { + if (strlen(sentence) == 0) { + WARNING_LOG("Input sentence is empty"); + std::string response = "HTTP/1.1 400 Empty sentence\r\n\r\n"; + mg_printf(conn, "%s", response.c_str()); + return 0; + } + + if (!isclear(strSentence)) { WARNING_LOG("Failed string validation check"); // Input sentence is not clear - std::string response = "HTTP/1.1 400 Bad Request\r\n\r\n"; - response += "Input string not well formated"; + std::string response = "HTTP/1.1 400 Encoding not in UTF8\r\n\r\n"; mg_printf(conn, "%s", response.c_str()); return 0; } @@ -138,7 +144,7 @@ static int Service(struct mg_connection *conn) { if(str_xml == "y") { if (-1 == xml4nlp.LoadXMLFromString(strSentence)) { // Failed the xml validation check - std::string response = "HTTP/1.1 400 Bad Request\r\n\r\n"; + std::string response = "HTTP/1.1 400 Bad XML format\r\n\r\n"; response += "Failed to load custom xml"; mg_printf(conn, "%s", response.c_str()); return 0; @@ -175,9 +181,6 @@ static int Service(struct mg_connection *conn) { xml4nlp.ClearDOM(); } - - std::string response = "HTTP/1.1 500 Internal Server Error\r\n\r\n"; - mg_printf(conn, "%s", response.c_str()); return 1; }