2013-08-04 29 views
0

我想知道什麼樣的服務器的迴應我了HTTPClient?這是一個普通的Apache HTTP服務器?如何創建的HttpServer /了HTTPClient

我需要知道我可以通過URL提交表單POST,類似於

http://myserver/post?message=text&submit=send

你能給我一些指點怎樣學習?

這是一個示例C++代碼的HTTPClient爲微控制器

HTTPMap map; 
HTTPText inText(str, 512); 
map.put("Hello", "World"); 
map.put("test", "1234"); 
printf("\nTrying to post data...\n"); 
ret = http.post("http://httpbin.org/post", map, &inText); 
if (!ret) 
{ 
    printf("Executed POST successfully - read %d characters\n", strlen(str)); 
    printf("Result: %s\n", str); 
} 
else 
{ 
    printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); 
} 

這是它返回

Trying to post data... 
Executed POST successfully - read 344 characters 
Result: { 
"headers": { 
"Content-Length": "21", 
"Content-Type": "application/x-www-form-urlencoded", 
"Host": "httpbin.org", 
"Connection": "close" 
    }, 
    "url": "http://httpbin.org/post", 
    "data": "", 
    "origin": "<//my IP>", 
    "args": {}, 
    "form": { 
    "Hello": "World", 
    "test": "1234" 
    }, 
    "json": null, 
    "files": {} 
} 

回答

0

它可以是任何HTTP服務器(Web服務器)的結果。您可以使用任何.NET語言構建獨立的HTTPServer,也可以編寫ISS的ISAPI插件或安裝PHP。

實際上,一個普通的web服務器也可以是一個web服務。不同之處通常在於Web服務器提供網頁服務,而服務提供特定的信息塊,通常不是以HTML格式,而是以JSON或另一種更友好的格式進行進一步處理。

它主要是一種語義上的差異,從技術上講幾乎沒有區別。