gpt4 book ai didi

iphone - ASIHTTPRequest 返回 HTML 而不是 JSON

转载 作者:行者123 更新时间:2023-12-03 20:25:53 25 4
gpt4 key购买 nike

我正在使用 ASIHTTPRequest 联系 API,问题是它返回 html 而不是 JSON,我不知道为什么。几周以来一切都运行良好,但我似乎不知道出了什么问题..

奇怪的是,使用浏览器或 postie 执行完全相同的请求会返回正确的 JSON 响应,但是当我通过 ASIHTTPRequest 执行请求时,这些是我得到的响应 header :

"Cache-Control" = "private, max-age=0, must-revalidate";
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=utf-8";
Date = "Tue, 05 Jul 2011 21:11:10 GMT";
Etag = "\"e467792713ac4124f055c1719f4ea6c2\"";
Server = "nginx/0.7.65";
Status = "200 OK";
"Transfer-Encoding" = Identity;
"X-Runtime" = 1;

还有 html(应该是 json)..

<div id="universal_meta" logged_in_user_id="removed" style="display:none"></div>
<div id="meta" screen="projects" logged_in_as="removed"></div>
<h1>9 projects with 50 open issues</h1>
<ul class="biglinks progressbars">
etc...

这是用于执行请求的代码..

NSURL *url = [NSURL URLWithString:path];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

if(secure){
[request setUsername:self.username];
[request setPassword:self.password];
}

[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[request setDownloadDestinationPath:destination];

[[self queue] addOperation:request]; //queue is an NSOperationQueue

我已经三次检查了所有登录详细信息/网址,一切都正确,我非常感谢任何有关此问题的帮助,因为我完全迷失了。

--

更新:

Lighthouse 承认存在有关其 header 的错误。等待他们的解决方案。

最佳答案

您是否检查过使用浏览器发送的 header 是否也与通过代码发送请求时相同?

特别是您是否尝试将“Accept” header 添加到您的请求中以定义您接受 json Content-Type?

[request addRequestHeader:@"Accept" value:@"application/json"];

关于iphone - ASIHTTPRequest 返回 HTML 而不是 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6589048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com