我正在使用Phonegap [cordova 1.7.0]使用Xcode [ios5]下载文件.这是我用来下载文件的代码:
function downloadfile(){
var fileTransfer = new FileTransfer();
console.log('the type of root is:');
fileTransfer.download(
"http://184.172.195.202:90/ElmNoor/Documents/1.txt",
persistent_root.fullPath,
function(entry) {
alert("I'm Downloading");
console.log("download complete: " + entry.fullPath);
},
function(error) {
alert("I'm not downloading");
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code " + error.code);
}
);}
Run Code Online (Sandbox Code Playgroud)
但我得到错误代码2我不知道我可以解决它吗?
这是我的日志:
HelloPhoneGap[933:13403] File Transfer Finished with response code 200
HelloPhoneGap[933:13403] [INFO] download error source http://184.172.195.202:90/ElmNoor/Documents/1.txt
HelloPhoneGap[933:13403] [INFO] download error target /Users/weekend/Library/Application Support/iPhone Simulator/5.1/Applications/A7883F4B-7678- …Run Code Online (Sandbox Code Playgroud) 我在HttpResponseHeaders中看到的唯一方法是Add,它采用字符串类型的字符串类型.我只是想知道.NET在字符串中提供了HttpResponseHeader类型的列表吗?
所以我可以这样做:
HttpResponseMessage response = Request.CreateResponse.........;
response.Headers.Add(xxxxx.ContentRange, "something");
Run Code Online (Sandbox Code Playgroud)
我可以看到HttpResponseHeader中有一个Enum列表,但是它没有提供相应的字符串值...
即HttpResponseHeader.ContentRange,但正确的标题字符串应为Content-Range
如果我错了,请纠正我......
我有一个在Amazon S3上托管的网页,但我不想要http响应代码200.该页面是一个维护页面,当我将主网站关闭进行维护时,我将重定向流量.
我希望Amazon S3页面包含一个响应头:
HTTP/1.1 503 Service unavailable
Run Code Online (Sandbox Code Playgroud)
亚马逊能够向S3对象添加一些元数据,但http状态代码没有任何内容.
可能吗?
浏览HTTP 响应代码.. 并了解这些响应代码(rcodes)代表什么
但我不确定在下面的情况下将向客户端/消费者(例如浏览器)发送什么 rcode。我使用 NGINX 作为反向代理,使用 Apache 作为 HTTP 服务器,在 NGINX 后面运行 Web 应用程序(例如应用程序)。
几个场景
应用程序中发生运行时错误,抛出 rcode 为 500(默认情况下运行时错误代码)。我的理解是nginx会继续抛出500而不将其转换为502?
应用程序已关闭或不可用。我的理解是 nginx 在这种情况下会抛出 503 而不是 502 ?
应用程序花费的时间比 nginx 默认连接超时时间还要长。我的理解是nginx在这种情况下会抛出504?
如果以上所有点都正确,不确定 nginx 何时会抛出 502 ?NGINX何时会认为从上游服务器收到的响应为无效响应?
web-applications nginx httpresponse http-response-codes nginx-reverse-proxy
我使用 Ansible 运行启动脚本,如下所示:
\n- name: Start service\n raw: "source ~/.profile; ~/start.sh"\nRun Code Online (Sandbox Code Playgroud)\n现在,我想继续检查上面启动的服务的 HTTP 状态,直到成功 \xe2\x80\x94 200。
下面是我如何检查 HTTP 状态200,但是,我不知道如何继续检查 2 分钟并报告 URL 是否仍然没有返回200。
- name: Detect if HTTp response is \'200\'\n uri:\n url: \'http://example.org/iportal/\'\n return_content: yes\n validate_certs: no\n status_code:\n - 200\n register: uri_output\nRun Code Online (Sandbox Code Playgroud)\n 我尝试使用 Java 库来验证可能的 HTTP 响应的范围,而不是编写自己的逻辑来单独检查每个响应代码。
Response.Status我在javax.ws.rs中找到了一个静态类,它似乎完全符合此目的。其文档指出:
HTTP 定义的常用状态代码,请参阅 HTTP/1.1 文档以获取完整列表。
如果您访问javax 文档引用的HTTP/1.1 文档 链接302,您会清楚地看到响应状态代码是有效的。
然而,以下调用返回null,意味着“匹配的 Status 或 null 是没有定义匹配的 Status”——这显然是不正确的:
Response.Status.fromStatusCode(302);
Run Code Online (Sandbox Code Playgroud)
果然,302/FOUND不在这个类定义的枚举中。
有谁知道这是为什么吗?这是代码中的疏忽javax.ws.rs——还是故意这样做的?
对于我正在开发的 REST API,客户可以注册一家公司,随后需要通过电子邮件进行确认/激活。收到以下示例请求后,将发送一封电子邮件,其中包含激活链接,以激活帐户。
POST /companies HTTP/1.1
<company>
<name>CoolCompany</name>
<email>coolcompany@example.com</email>
</company>
Run Code Online (Sandbox Code Playgroud)
如果上述请求成功(有效数据,电子邮件成功发送),公司资源将保存在数据库中,但只有在/companies/<id>收到确认后(给定适当的授权标头)才可用。
鉴于这种情况,是
HTTP/1.1 202 Accepted
// Perhaps optionally with a Location header,
// of where the resource will be available, as well?
Location: /companies/<id>
Run Code Online (Sandbox Code Playgroud)
适当的回应?或者会
HTTP/1.1 201 Created
Location: /companies/<id>
Run Code Online (Sandbox Code Playgroud)
是更合适的回应?
我正在尝试401在我的应用程序中返回响应状态AngularJS。但在我看到的控制台中,它返回-1
我在 php 中使用的是:
header("HTTP/1.1 401 Unauthorized");
http_response_code(401);
Run Code Online (Sandbox Code Playgroud)
也在代码点火器中:
$this->output->set_header('HTTP/1.1 401 Unauthorized');
$this->output->set_status_header(401, "my status text");
Run Code Online (Sandbox Code Playgroud)
它在状态代码中工作良好,例如: 200 、 205 、 206 等。
任何想法?
php codeigniter http-response-codes http-status-code-401 angularjs
我希望返回 202 - HttpStatusCode.Accepted - 以及一个字符串值。
这怎么写:
[HttpPost]
public async Task<IActionResult> Post()
{
return Accepted(); //+ "my string value"
}
Run Code Online (Sandbox Code Playgroud) 出色地。我有一个问题http_response_code(),我找不到解释。如果我使用header()before http_response_code(),PHP 将返回由设置的 HTTP 状态header()并忽略任何http_response_code().
例如,我有一个文件:
<?php
header('HTTP/1.1 404 Not Found');
file_put_contents('./log',http_response_code(501).PHP_EOL,FILE_APPEND);
file_put_contents('./log',http_response_code(502).PHP_EOL,FILE_APPEND);
file_put_contents('./log',http_response_code(503).PHP_EOL,FILE_APPEND);
Run Code Online (Sandbox Code Playgroud)
(我用于file_put_contents()防止任何输出,因为有人可以说,这是这个问题的答案)
我使用默认的 php-server (但问题可以用 NGINX 重现):
<?php
header('HTTP/1.1 404 Not Found');
file_put_contents('./log',http_response_code(501).PHP_EOL,FILE_APPEND);
file_put_contents('./log',http_response_code(502).PHP_EOL,FILE_APPEND);
file_put_contents('./log',http_response_code(503).PHP_EOL,FILE_APPEND);
Run Code Online (Sandbox Code Playgroud)
有要求:
php -S localhost:9985
Run Code Online (Sandbox Code Playgroud)
有回应:
HTTP/1.1 404 Not Found
Host: localhost:9958
Date: Wed, 15 Sep 2021 17:20:05 GMT
Connection: close
X-Powered-By: PHP/8.0.10
Content-type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
并且有日志:
404
501
502
Run Code Online (Sandbox Code Playgroud)
响应包括第一行:
HTTP/1.1 404 Not Found
Run Code Online (Sandbox Code Playgroud)
但我在等待HTTP/1.1 503 Service Unavailable。日志文件包含预期数据,并显示http_response_code …
c# ×2
php ×2
.net ×1
amazon-s3 ×1
angularjs ×1
ansible ×1
asp.net-core ×1
codeigniter ×1
cordova ×1
fastcgi ×1
http-headers ×1
httpresponse ×1
java ×1
javascript ×1
nginx ×1
rest ×1
until-loop ×1
url ×1
wait ×1
xcode ×1