cpprestsdk http_listener忽略 # 之后的所有内容
cpprestsdk http_listener ignoring everything after #
>编辑:请参阅我下面的帖子,了解如何解决此问题。
我正在构建一个客户端应用程序,该应用程序将在用户保管箱应用程序文件夹中存储一些数据。所以目前我正在使用隐式授权,它将用户重定向到给定的重定向 uri,并在 url 中的 # 之后传递参数
例:
本地主机:1666/保管箱#access_token=...&token_type=...
通过本地主机 url 创建 http 侦听器,它会检测请求,但是 # 之后的所有内容都会被忽略,并且不会作为请求的一部分传递。有没有办法在#之后捕获数据,或者是否有任何其他库允许我这样做?
我正在使用 cpprestsdk https://github.com/microsoft/cpprestsdk
web::http::experimental::listener::http_listener* l = new web::http::experimental::listener::http_listener(m_authConfig.redirect_uri());
l->support([this](web::http::http_request request) -> void
{
auto uri = request.request_uri();
auto requestPath = web::uri::split_path(uri.path());
auto queryObjects = web::uri::split_query(uri.query());
auto s = uri.fragment();
if (request.request_uri().path() == U("/Dropbox")) && request.request_uri().query() != U(""))
{
request.reply(web::http::status_codes::OK, U("ok.") + uri.query());
}
else
{
request.reply(web::http::status_codes::OK, U("error.") + uri.query());
}
});
l->open().wait();
谢谢!
所以经过一番研究,事实证明#(片段(在大多数浏览器中都不会发回,所以为了能够获取数据,我返回以下java脚本脚本:
<script> window.location.replace([location.protocol, '//', location.host, location.pathname, '?', location.hash.substring(1,location.hash.length )].join(''));</script>
这会将哈希部分转换为查询字符串,并将其重定向到用户,以便侦听器检测到它。
相关文章:
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 在类定义之后定义一个私有方法
- 在循环C++中指定字符串之后,不会打印该字符串
- 如何在boost beast http请求中设置http头
- C++宏忽略之后的内容
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 在多个核心中处理一个HTTP请求
- SFML library: http request
- strncpy之后的char数组的错误行为
- 计算十进制 c++ 之后的数字
- "x += x--"之后的 x 是什么?
- 类的前向声明之后的类成员函数定义,在类声明之前
- 为什么将双精度转换为 int 似乎在第 16 位数字之后将其四舍五入?
- execlp() 在 fork() 之后无法正常工作
- 使用 Winsock2.h C++向不和谐 API 发送 HTTP 请求时出现问题
- 我认为我的代码很好,但它在 cin a 之后停止并且没有进一步?
- 如何在MISRA C++之后实施CRTP
- 在 OpenCV 的 namedWindow 之前或之后初始化 Tesseract
- 通过单独的 tcp 流建立 http 连接
- http请求之前和之后的垃圾