http libevent api 服務:ehttp-api
ehttp-api
http libevent api service
Dependencies
以下需要安裝
- libevent http://libevent.org/
- libcurl http://curl.haxx.se/
- hiredis https://github.com/redis/hiredis
- libevhtp https://github.com/ellzey/libevhtp
- libzdb https://github.com/mverbert/libzdb http://www.tildeslash.com/libzdb
- zlog http://hardysimpson.github.com/zlog/
- TCMalloc https://github.com/gperftools/gperftools
- openssl https://github.com/openssl/openssl
以下不需要安裝
- cJSON https://github.com/kbranigan/cJSON http://cjson.sourceforge.net/
- nginx 的部分源碼
install guide
Except cJSON:
$ wget DPND $ tar xf DPND.tar* $ cd DPND $ ./configure # Optional, if it has $ make $ sudo make install # libevhtp 的特殊處理 由于內網的 http 服務,可以將 openssl 禁掉. $ cd libevhtp-* $ vim evhtp.h 加入以下內容: #define EVHTP_DISABLE_SSL 1 安裝成功后執行: $ cd /usr/local/include/evhtp $ sudo cp * ../ # libzdb 安裝后的特殊處理 $ cd /usr/local/include/zdb $ sudo cp * ../
注意事項
新 clone 的項目請依次執行以下的命令:
$ git submodule init $ git submodule update
需要參考 conf 目錄中 *.sample.conf 配置生成開發或線上環境服務配置文件.
$ cp conf/server.sample.json conf/server.json $ cp conf/zlog.sample.conf conf/zlog.conf 將配置文件中修改為真實可用的資源.
Q&A
dyld: Library not loaded: libmysqlclient.18.dylib
Mac 下報錯: 參考方法: $ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
bigint 如何處理?
傳輸出層采用字符串,業務使用的時候轉成數字.
#include <stdlib.h>
long
strtol(const char *restrict str, char **restrict endptr, int base);
long long
strtoll(const char *restrict str, char **restrict endptr, int base);
unsigned long
strtoul(const char *restrict str, char **restrict endptr, int base);
unsigned long long
strtoull(const char *restrict str, char **restrict endptr, int base);
如何防SQL注入
- 優先考慮使用
Connection_prepareStatement
. -
其次,由于客戶端提交數據經過 filter 處理后,變成了 cJSON 對象,會對字符串中的雙引號加上轉義符,如果是手工拼 SQL,只要用雙引號引起字符串即可防注入.形如:
ResultSet_T result = Connection_executeQuery(db, "SELECT id, nickname, mobile, email FROM demo WHERE email = \"%s\"", email->valuestring);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!