1
有一個較早實現從C語言POS系統到服務器的獲取和發佈http請求。但出於安全原因,服務器僅接受端口443上的https。http獲取請求與c中的https請求有什麼不同?
該實施未能在端口443上工作,指示http錯誤400/362。
下面是示例代碼,
char *build_get_query(char *host, char *page)
{
char *query;
char *getpage = page;
char *tpl = "GET /%s HTTP/1.0\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n";
/*if(getpage[0] == '/'){
getpage = getpage + 1;
fprintf(stderr,"Removing leading \"/\", converting %s to %s\n", page, getpage);
} */
// -5 is to consider the %s %s %s in tpl and the ending \0
query = (char *)malloc(strlen(host)+strlen(getpage)+strlen(USERAGENT)+strlen(tpl)-5);
sprintf(query, tpl, getpage, host, USERAGENT);
return query;
}
P.S沒有專家位於C 謝謝
請分享更多詳情我可以傳遞給我的開發人員 – Acacia
爲什麼你會像這樣幫助你的開發者,僱用另一個。如果你想寫信給[email protected],我現在正在研究一個完全符合你需要的庫。使用'printf()'類似funcionality並且啓用TLS或根據需要不啓用它。它已經準備好,寫信給我,我們可以談論它。 –