通過C# 來簡單實現一個http服務器,來大概了解http get和post數據的大概方式。
簡單實現post數據 ContentType其中=的三種方式。
private void handleContentType(HttpListenerContext context) { if (context.Request.ContentType.Contains("multipart/form-data")) { handlePostMultipart(context); } else if (context.Request.ContentType.Contains("application/x-www-form-urlencoded")) { handleFormUrlencoded(context); } else if (context.Request.ContentType.Contains("application/json")) { handleJson(context); } else { new processSendClient(context).write("post請求的數據:" + context.Request.ContentType); } }
vs2013下編譯通過。
https://files-cdn.cnblogs.com/files/gogosai/httpServer.zip?t=1648293903