You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2009/02/17 12:50:52 UTC
svn commit: r744968 - in /incubator/shindig/trunk/php/src/gadgets:
MakeRequestHandler.php ProxyHandler.php
Author: chabotc
Date: Tue Feb 17 11:50:52 2009
New Revision: 744968
URL: http://svn.apache.org/viewvc?rev=744968&view=rev
Log:
Don't set caching headers of the http code was no 200, and makeRequest should return a 200 OK on failed fetching, and only have the error code in the json structure
Modified:
incubator/shindig/trunk/php/src/gadgets/MakeRequestHandler.php
incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
Modified: incubator/shindig/trunk/php/src/gadgets/MakeRequestHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/MakeRequestHandler.php?rev=744968&r1=744967&r2=744968&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/MakeRequestHandler.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/MakeRequestHandler.php Tue Feb 17 11:50:52 2009
@@ -56,7 +56,6 @@
die();
}
$status = (int)$result->getHttpCode();
- header("HTTP/1.1 $status", true);
header("Content-Type: application/json; charset=utf-8", true);
$output = '';
if (isset($_REQUEST['contentType']) && $_REQUEST['contentType'] == 'FEED' && $status == 200) {
@@ -67,7 +66,10 @@
$json = array($url => array('body' => $resp, 'rc' => $status));
$json = json_encode($json);
$output = UNPARSEABLE_CRUFT . $json;
- $this->setCachingHeaders();
+ if ($status == 200) {
+ // only set caching headers if the result was 'OK'
+ $this->setCachingHeaders();
+ }
echo $output;
}
Modified: incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php?rev=744968&r1=744967&r2=744968&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php Tue Feb 17 11:50:52 2009
@@ -38,26 +38,17 @@
public function fetch($url) {
$url = $this->validateUrl($url);
$result = $this->fetchContent($url, 'GET');
- $status = (int)$result->getHttpCode();
- header("HTTP/1.0 $status", true);
- $headers = explode("\n", $result->getResponseHeaders());
+ $httpCode = (int)$result->getHttpCode();
$isShockwaveFlash = false;
- foreach ($headers as $header) {
- if (strpos($header, ':')) {
- $key = trim(substr($header, 0, strpos($header, ':')));
- $key = str_replace(' ', '-', ucwords(str_replace('-', ' ', $key))); // force the header name to have the proper Header-Name casing
- $val = trim(substr($header, strpos($header, ':') + 1));
- // filter out headers that would otherwise mess up our output
- if (! in_array($key, $this->disallowedHeaders)) {
- header("$key: $val", true);
- } else {
- }
- if ($key == 'Content-Type' && strtolower($val) == 'application/x-shockwave-flash') {
- // We're skipping the content disposition header for flash due to an issue with Flash player 10
- // This does make some sites a higher value phishing target, but this can be mitigated by
- // additional referer checks.
- $isShockwaveFlash = true;
- }
+ foreach ($result->getResponseHeaders() as $key => $val) {
+ if (! in_array($key, $this->disallowedHeaders)) {
+ header("$key: $val", true);
+ }
+ if ($key == 'Content-Type' && strtolower($val) == 'application/x-shockwave-flash') {
+ // We're skipping the content disposition header for flash due to an issue with Flash player 10
+ // This does make some sites a higher value phishing target, but this can be mitigated by
+ // additional referer checks.
+ $isShockwaveFlash = true;
}
}
if (! $isShockwaveFlash) {
@@ -73,7 +64,10 @@
$notModified = true;
}
}
- $this->setCachingHeaders($lastModified);
+ if ($httpCode == 200) {
+ // only set caching headers if the result was 'OK'
+ $this->setCachingHeaders($lastModified);
+ }
// If the cached file time is within the refreshInterval params value, return not-modified
if ($notModified) {
header('HTTP/1.0 304 Not Modified', true);