如果HTTP服务器发送带有Content-Length标头的回复和略大于该长度的消息体,那么处理这种不匹配的方法是什么?我应该默默地忽略额外的数据吗?我没有在HTTP/1.1 RFC中看到这个,它只是说应该始终匹配.看起来可能有一些错误的服务器在那里没有做到这一点.
谢谢.
是否有任何直接的方法来发出HTTP请求并获得原始的,未解析的响应(特别是标题)?
我使用以下输出缓存配置文件:
<add name="MyFunkyProfile" duration="180" varyByParam="*" location="ServerAndClient" />
Run Code Online (Sandbox Code Playgroud)
在dev中,我有一个带有一个Vary条目的响应头:
HTTP/1.1 200 OK
Server: Microsoft-IIS/7.5
...
Vary: Accept-Encoding
Cache-Control: private, max-age=180, s-maxage=0
...
Run Code Online (Sandbox Code Playgroud)
当我部署我的应用程序时,我在响应中插入了额外的Vary条目:
HTTP/1.1 200 OK
Server: nginx
...
Vary: Accept-Encoding
Cache-Control: private, max-age=180, s-maxage=0
...
Vary: *
...
Run Code Online (Sandbox Code Playgroud)
为什么这个额外的Vary条目?这会阻止缓存正常工作.
任何想法如何解决这一问题?
asp.net-mvc outputcache http-headers asp.net-mvc-3 appharbor
我想从我的服务器上直接将视频上传到Youtube,我正在使用PHP curl.
我需要这种请求格式:
POST /feeds/api/users/default/uploads HTTP/1.1
Host: uploads.gdata.youtube.com
Authorization: Bearer ACCESS_TOKEN
GData-Version: 2
X-GData-Key: key=adf15ee97731bca89da876c...a8dc
Slug: video-test.mp4
Content-Type: multipart/related; boundary="f93dcbA3"
Content-Length: 1941255
Connection: close
--f93dcbA3
Content-Type: application/atom+xml; charset=UTF-8
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<media:group>
<media:title type="plain">Bad Wedding Toast</media:title>
<media:description type="plain">
I gave a bad toast at my friend's wedding.
</media:description>
<media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People
</media:category>
<media:keywords>toast, wedding</media:keywords>
</media:group>
</entry>
--f93dcbA3
Content-Type: video/mp4
Content-Transfer-Encoding: binary
<Binary File Data>
--f93dcbA3--
Run Code Online (Sandbox Code Playgroud)
这就是我所拥有的:
$content = $this->buildRequestContent();
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads', …Run Code Online (Sandbox Code Playgroud) 我正在创建一个页面,其中有一些数据可以被另一个设备解析.我以前用php做这个,但我把它移到节点.我需要从页面中删除任何和所有标题,所以我只有我的输出.此输出是对GET请求的响应.
目前我有
HTTP/1.1 200 OK
Date: Wed, 11 Sep 2013 11:54:14 GMT
Connection: close
My output
Run Code Online (Sandbox Code Playgroud)
我需要它才能显示
My output
Run Code Online (Sandbox Code Playgroud) 如何使用JavaScript/jQuery处理/解析/读取"multipart/mixed; boundary = batch"类型的响应?
在我们的应用程序中,我们得到如下响应:
有没有办法处理这类回复?或者我们应该使用正则表达式等原始字符串操作来获取我们想要的内容?
--batchresponse_e3e3tc10-1181-4b94-bb8a-952452769d53
Content-Type: multipart/mixed; boundary=changesetresponse_4sdflwerf-40ef-4347-8c77-b364e5d2e678
--changesetresponse_4sdflwerf-40ef-4347-8c77-b364e5d2e678
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 201 Created
DataServiceVersion: 1.0;
Content-Type: application/json;odata=verbose;charset=utf-8
Content-ID: 1
X-Content-Type-Options: nosniff
Cache-Control: no-cache
Location: <url1>
{"Some": "JSON response"}
--changesetresponse_4sdflwerf-40ef-4347-8c77-b364e5d2e678
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 204 No Content
Content-ID: 2
X-Content-Type-Options: nosniff
Cache-Control: no-cache
DataServiceVersion: 1.0;
--changesetresponse_4sdflwerf-40ef-4347-8c77-b364e5d2e678
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 204 No Content
Content-ID: 3
X-Content-Type-Options: nosniff
Cache-Control: no-cache
DataServiceVersion: 1.0;
--changesetresponse_4sdflwerf-40ef-4347-8c77-b364e5d2e678--
--batchresponse_e3e3tc10-1181-4b94-bb8a-952452769d53--
Run Code Online (Sandbox Code Playgroud) 所以我的时间表总是这样
http://see.kirkstrobeck.com/TjQU/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png
该index.html负载,然后询问其他文件.我想有没有办法让响应请求的标题说明应该删除哪些文件?所以它看起来像这样..
http://see.kirkstrobeck.com/TjKl/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png
也许像..
<?
header('fileGetRequest: /js/common.js');
header('fileGetRequest: /css/common.css');
?>
Run Code Online (Sandbox Code Playgroud) 我发现信息的Internet Explorer 5或可能IIS 4.0的预检查和检查后缓存控制头推出的支持.我还没有找到关于IE 8,9,10和11等更高版本是否仍然支持它们的更多信息.
我想在应用程序中删除对它们的支持,但希望不再使用它们的数据.
我只是GET使用一个Rest API请求HttpURLConnection.
我需要添加一些自定义标头,但我null在尝试检索其值时得到.
码:
URL url;
try {
url = new URL("http://www.example.com/rest/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// Set Headers
conn.setRequestProperty("CustomHeader", "someValue");
conn.setRequestProperty("accept", "application/json");
// Output is null here <--------
System.out.println(conn.getHeaderField("CustomHeader"));
// Request not successful
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Request Failed. HTTP Error Code: " + conn.getResponseCode());
}
// Read response
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuffer jsonString = new StringBuffer();
String line;
while ((line = br.readLine()) != null) { …Run Code Online (Sandbox Code Playgroud) 我在我的PHP脚本(PHP 5.6,Apache 2.2)中间歇性地遇到了这个问题:
警告:无法修改标头信息 - 已在第55行的/path/to/index.php中发送的标头
这个警告没有我在其他问题中看过的"发送者"部分,所以我在犯罪header()和setcookie()调用之前添加了这段代码:
if (headers_sent($filename, $linenum)){
echo("Output buffer: #" . ob_get_contents() . "#");
echo "Headers already sent in $filename on line $linenum: ";
print_r(headers_list());
}
Run Code Online (Sandbox Code Playgroud)
这是问题发生时我得到的输出:
Output buffer: ##
Headers already sent in on line 0:
Array (
[0] => X-Powered-By: PHP/5.6.23
[1] => Content-type: text/html; charset=UTF-8
)
Run Code Online (Sandbox Code Playgroud)
(旁注:我在php.ini中将output_buffering设置为4096字节,所以这两个标题中的63个字符是否应该被缓存并等待更多,而不是过早发送?)
第一次启动包含Web服务器的Docker容器时出现此问题.之后,当我第一次访问我的网站(可能是一两个小时),当我打电话并登录用户或重定向到登录页面时,它只会(但不总是)发生.header()setcookie()
我已阅读并重读了一般"已发送标题"错误的答案,并且尽我所能,我已排除了这些可能的原因:
print,echo等等.在我调用setcookie()或header()auto_prepend_file php.ini设置gzip流编码 - …http-headers ×10
http ×5
http-request ×2
javascript ×2
php ×2
appharbor ×1
asp.net-mvc ×1
browser ×1
curl ×1
express ×1
java ×1
node.js ×1
outputcache ×1
php-5.6 ×1
python ×1
rest ×1