使用 c++ 发布 html 页面
Posting a html page using c++
我正在尝试使用c ++发布一个html页面。我使用实现 tcpsoketing 的套接字构建了一个类。我检查了一下,它起作用了。所以我认为我的问题出在我发送的内容上:
string s = "<!DOCTYPE html><html><head><title>home.html</title></head><body><form name='input' action='login.html' method='get'>user name: <input type='text' name='user'><br>password: <input type='text' name='password'><input type='submit' value='Submit'> </form></body></html>";
string str="POST /home.html HTTP/1.1rnHost: 127.0.0.1:22225rnUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36rnAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8rnAccept-Language: en-US,en;q=0.8Accept-Encoding: gzip,deflate,sdchrnrnrnrnConnection: keep-alivernContent-Type: application/x-www-form-urlencodedrnContent-Length: 2048"+s;
你的怀疑是正确的。您的请求消息格式不正确。请参阅 RFC 7230,第 3 节:https://www.rfc-editor.org/rfc/rfc7230#section-3
HTTP-message = start-line
*( header-field CRLF )
CRLF
[ message-body ]
密切注意每个标题字段后需要使用多少行尾。
提示:标头块和消息正文用 CRLF CRLF
分隔。
确保在标题和正文之间有一个空行(在 RFC 7230 中指定),例如
HTTP/1.1 200 OK
Server: Apache/1.3.29 (Unix) PHP/4.3.4
Content-Length: 123456
Content-Language: de
Connection: close
Content-Type: text/html
<!DOCTYPE html><html></html>
相关文章:
- 简单的 HTML 验证器
- 如何在 html 页面中插入 cgi 应用程序的输出?
- 代码精简版页面变为空白
- 如何使用utf-8编码在Qt5 WebEngineView中加载HTML页面?
- 为什么由服务器重新保留的HTML页面没有在浏览器中渲染
- 如何将OpenCV的输出显示或流式传输到HTML页面或其他一些客户端应用程序
- 合适的C 小部件,用于显示静态HTML页面
- Qt QNetworkAccessManager 或其他方法获取 html 状态代码而不获取页面 contenet
- Howto在QString中存储HTML代码时,默认浏览器中打开HTML页面
- 如何从 POCO websocket 服务器解析 html 页面
- 显示html页面
- 使用 c++ 发布 html 页面
- 将图像文件从 MFC 应用流式传输到 HTML 页面
- Qt c++如何在加载新的HTML页面后释放内存
- 是否有用于从HTML页面中提取数据的库
- 是否可以从命令行运行最小化HTML的页面速度
- 如何使用winsock2通过代理下载html页面
- 使用Firebreath为Chrome创建的NPAPI我可以从扩展而不是从HTML加载页面调用插件方法
- 在 JSON - AJAX 发布请求后保存 html 页面
- 如何从HTML页面获取字符集