如何使用libcurl提取Location:HTTP头字段
How to extract the Location: HTTP header field with libcurl?
我在应用程序中使用libcurl作为http客户端。我可以使用libcurl发送和接收http消息。
当我得到如上所述的具有http 302的消息时,我想要从接收到的http消息中提取location
字段。
HTTP/1.1 302 Found
Location: http://192.168.201.1
Content-Length: 0
当我收到http 302消息时,如何提取location
字段?
如果您需要经过处理的绝对URL,那么在重定向时,请使用CURLINFO_redirect_URL选项。另请参阅getredirect示例。
当您需要Location
标头的原始值时,您需要实现CURLOPT_HEADERFUNCTION回调并等待标头到达。
相关文章:
- 将结构字段的类型展开为可变模板参数
- 将位字段导出到数组
- 为了方便起见,我应该避免公开私有字段变量吗
- 当字段可以为null时,如何使用C++接口在Avro中写入数据
- 在java中读取c++字节的位字段
- 链接器找不到在虚拟类 c++ 中访问的静态字段的符号
- 私有字段对象与私有继承?
- 声明没有默认构造函数的字段
- C++内存模型和位字段的最大序列
- 声明为无效的变量或字段'...' Ardunio 编译器上的错误
- 如何在QByteArray中放置和检索位字段而不会感到痛苦?
- C++ win32 如何使密码字段可选并启用复制和粘贴?
- 如何通过UDP接收QByteArray并将其解析为位字段结构?
- 仅匹配集合中的某些字段
- 结构字段名称与 GDB 中的 STL 数组冲突
- 如何使用位字段将数据从二进制文件复制到结构中?
- 结构体和类的不同大小(),彼此具有相同的字段类型
- 无法识别 HTTP 标头字段
- 如何使用libcurl提取Location:HTTP头字段
- HTTP Post报头字段libcurl