如何从 TIdHTTP get 中读取 header
How to read the header from a TIdHTTP get
我正在使用 TIdHTTP.Get()
检索 JSON 格式的记录。它只会向我发送前 1000 条记录,并且在 header 中它将包含下 1000 条记录的 URL,如果有的话。
我可以在 PostMan 中看到 header,但如何通过此调用访问它?
jsontxt := IdHTTP1.Get(url);
一旦 TIdHTTP.Get()
退出,原始响应 header 可以通过 TIdHTTP.Response.RawHeaders
属性 访问。许多 header 在 TIdHTTP.Response
object 中也有自己专用的 sub-property。如果你想要的header没有,你可以用RawHeaders.Values[]
属性来读,eg:
jsontxt := IdHTTP1.Get(url);
url := IdHTTP1.Response.RawHeaders.Values['the-next-url-header'];
如果header不存在,Values[]
将只是return一个空字符串,例如:
url := ...;
repeat
jsontxt := IdHTTP1.Get(url);
//...
url := IdHTTP1.Response.RawHeaders.Values['the-next-url-header'];
until url = '';
我正在使用 TIdHTTP.Get()
检索 JSON 格式的记录。它只会向我发送前 1000 条记录,并且在 header 中它将包含下 1000 条记录的 URL,如果有的话。
我可以在 PostMan 中看到 header,但如何通过此调用访问它?
jsontxt := IdHTTP1.Get(url);
一旦 TIdHTTP.Get()
退出,原始响应 header 可以通过 TIdHTTP.Response.RawHeaders
属性 访问。许多 header 在 TIdHTTP.Response
object 中也有自己专用的 sub-property。如果你想要的header没有,你可以用RawHeaders.Values[]
属性来读,eg:
jsontxt := IdHTTP1.Get(url);
url := IdHTTP1.Response.RawHeaders.Values['the-next-url-header'];
如果header不存在,Values[]
将只是return一个空字符串,例如:
url := ...;
repeat
jsontxt := IdHTTP1.Get(url);
//...
url := IdHTTP1.Response.RawHeaders.Values['the-next-url-header'];
until url = '';