Skip to content

Commit

Permalink
Web service only support utf-8 and POST
Browse files Browse the repository at this point in the history
  • Loading branch information
carfly committed Jul 21, 2013
1 parent 97cdc0f commit 4c18636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/__xml4nlp/Xml4nlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,8 @@ int XML4NLP::InitXmlWord(vector<Word_t> &vecWord_t, TiXmlElement *wordPtr)
/////////////////////////////////////////////////////////////////////////////////////
int XML4NLP::BuildDOMFrame()
{
TiXmlDeclaration* xmlDeclaration = new TiXmlDeclaration("1.0", "gb2312", "");
// TiXmlDeclaration* xmlDeclaration = new TiXmlDeclaration("1.0", "gb2312", "");
TiXmlDeclaration* xmlDeclaration = new TiXmlDeclaration("1.0", "utf-8", "");
m_tiXmlDoc.LinkEndChild(xmlDeclaration);
// TiXmlXSLDeclaration* xslDeclaration = new TiXmlXSLDeclaration("text/xsl", "nlp_style_v2.0.xsl");
// TiXmlDeclaration* xslDeclaration = new TiXmlDeclaration("text/xsl", "http://ir.hit.edu.cn/demo/ltp/nlp_style_v2.0.xsl", "");
Expand Down
12 changes: 10 additions & 2 deletions src/server/ltp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,22 @@ static int Service(struct mg_connection *conn)
const struct mg_request_info *ri = mg_get_request_info(conn);

if (!strcmp(ri->uri, "/ltp")) {
const char *qs = ri->query_string;
post_data_len = mg_read(conn, post_data, sizeof(post_data));
cout << post_data_len << " " << post_data << endl;

/*const char *qs = ri->query_string;
cout << "query_string: " << qs << endl;
mg_get_var(qs, strlen(qs == NULL ? "" : qs), "s", sentence, sizeof(sentence));
cout << "sentence: " << sentence << endl;
mg_get_var(qs, strlen(qs == NULL ? "" : qs), "t", type, sizeof(type));
mg_get_var(qs, strlen(qs == NULL ? "" : qs), "x", xml, sizeof(xml));

*/
mg_get_var(post_data, post_data_len, "s", sentence, sizeof(sentence));
mg_get_var(post_data, post_data_len, "t", type, sizeof(type));
mg_get_var(post_data, post_data_len, "x", xml, sizeof(xml));

if (strcmp(sentence, "") == 0)
return 0;

Expand Down

0 comments on commit 4c18636

Please sign in to comment.