header 状态代码(Status)

本文详细介绍了HTTP协议中各种状态代码的含义及用途,包括信息响应、成功响应、重定向、客户端错误及服务器错误等类别,并提供了PHP设置状态代码的例子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Header出状态代码(Status)

<?php

 

header("http/1.1 403 Forbidden"); 

 

?> 

 

第一部分为HTTP协议的版本(HTTP-Version) 

 

第二部分为状态代码(Status) 

 

第三部分为原因短语(Reason-Phrase) 

 

三部分中间用一个空格分开,且中间不能有回车,第一部分和第二部分是必需的,第三部分则是给人看的,可写可不写甚至乱写。 

 

还有,这一句的输出必须在Html文件的第一行。 

 

下面是从w3.org制定的规范: 

 

  * 1xx: Informational - Request received, continuing process 

 

  * 2xx: Success - The action was successfully received, understood, 

 

  and accepted 

 

  * 3xx: Redirection - Further action must be taken in order to 

 

  complete the request 

 

  * 4xx: Client Error - The request contains bad syntax or cannot be 

 

  fulfilled 

 

  * 5xx: Server Error - The server failed to fulfill an apparently 

 

  valid request 

 

 

       | "100" ; Continue 

 

       | "101" ; Switching Protocols 

 

       | "200" ; OK 

 

       | "201" ; Created 

 

       | "202" ; Accepted 

 

       | "203" ; Non-Authoritative Information 

 

       | "204" ; No Content 

 

       | "205" ; Reset Content 

 

       | "206" ; Partial Content 

 

       | "300" ; Multiple Choices 

 

       | "301" ; Moved Permanently 

 

       | "302" ; Moved Temporarily 

 

       | "303" ; See Other 

 

       | "304" ; Not Modified 

 

       | "305" ; Use Proxy 

 

       | "400" ; Bad Request 

 

       | "401" ; Unauthorized 

 

       | "402" ; Payment Required 

 

       | "403" ; Forbidden 

 

       | "404" ; Not Found 

 

       | "405" ; Method Not Allowed 

 

       | "406" ; Not Acceptable 

 

       | "407" ; Proxy Authentication Required 

 

       | "408" ; Request Time-out 

 

       | "409" ; Conflict 

 

       | "410" ; Gone 

 

       | "411" ; Length Required 

 

       | "412" ; Precondition Failed 

 

       | "413" ; Request Entity Too Large 

 

       | "414" ; Request-URI Too Large 

 

       | "415" ; Unsupported Media Type 

 

       | "500" ; Internal Server Error 

 

       | "501" ; Not Implemented 

 

       | "502" ; Bad Gateway 

 

       | "503" ; Service Unavailable 

 

       | "504" ; Gateway Time-out 

 

       | "505" ; HTTP Version not supported 

在泛微OA(Office Automation System)中,查询流程状态通常需要通过其提供的API或者Web服务来进行。具体的代码会依赖于你使用的开发语言、OA系统的版本以及你对系统API的理解。以下是一个简单的示例,假设你使用的是Java,并且已经获取了OA系统的访问凭证: ```java import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class OAProcessStatusQuery { private static final String URL = "http://your-oa-server/process-instance/{processInstanceId}"; public static void main(String[] args) throws Exception { CloseableHttpClient httpClient = HttpClients.createDefault(); try { HttpGet request = new HttpGet(URL.replace("{processInstanceId}", "12345")); // replace with your process instance ID request.addHeader("Authorization", "Bearer your_access_token"); // replace with your API token CloseableHttpResponse response = httpClient.execute(request); try { if (response.getStatusLine().getStatusCode() == 200) { HttpEntity entity = response.getEntity(); String statusJson = EntityUtils.toString(entity); // 解析json并获取流程状态 JSONObject workflowStatus = new JSONObject(statusJson); String status = workflowStatus.getString("status"); System.out.println("流程状态: " + status); } else { System.err.println("请求失败, 状态码: " + response.getStatusLine()); } } finally { response.close(); } } finally { httpClient.close(); } } } ``` 请注意,这段代码只是一个基本的示例,实际应用中可能还需要处理异常、错误解析以及更复杂的权限验证。另外,你需要替换URL中的`{processInstanceId}`和`your_access_token`为实际的流程实例ID和你的API令牌。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值