When trying to load an .m3u8 file, my receiver's log are showing [cast.player.api.Host] error: cast.player.api.ErrorCode.NETWORK/3110 and the video fails to play.
The response headers according to the Chrome inspector:
Access-Control-Allow-Origin:*
CF-RAY:3b8ada35b5de6db4-SJC
Connection:keep-alive
Date:Sat, 04 Nov 2017 22:01:32 GMT
Server:cloudflare-nginx
Transfer-Encoding:chunked
X-Robots-Tag:noindex
...the Response tab of the Chrome Inspector is empty for the .m3u8 file request, so I am assuming that the response was discarded by the browser. Does the cast receiver have additional requirement to enable CORS, beyond the Access-Control-Allow-Origin header? Could it be an issue with the response body as opposed to the headers?
Related
I am trying to test a call to my local Django development server. This is an AJAX call that returns a JSON object. The Django view does this:
return JsonResponse(response, safe=False)
I test this by launching the Django server (which runs the back end) and then launching my browser and opening the HTML page I have modified. These pages are not served by Django.
In Firefox, I can make the ajax call on the page. It returns the correct data, with the correct MIME type.
In Chrome, I can not. I get the following error:
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://localhost:8000/dataload/alljson with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
I have tried to search for the solution to this problem. I've checked this question, but the suggestion to clear my cache doesn't do anything. I've also found suggestions that involve using django-cors-headers, but this is CORB (not CORS). Nonetheless, I've installed corsheaders and set CORS_ORIGIN_ALLOW_ALL = True to eliminate that as a possibility.
My MIDDLEWARE setting has this
MIDDLEWARE = [
...
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
...
]
The response headers I get in Firefox are:
Content-Length 12827
Content-Type application/json
Date Wed, 06 Feb 2019 18:38:03 GMT
Server WSGIServer/0.2 CPython/3.6.7
Vary Origin
X-Frame-Options SAMEORIGIN
I am calling http://localhost:8000/dataload/alljson. If I call http://localhost:8000/dataload/alljson/ (with the trailing slash), I get a 404.
Still no dice.
How can I get Chrome to allow the response from my development Django server for this ajax call?
I'm trying to download transactions from a bank account (mine).
Step 1: a form is filled and submitted (POST).
Step 2. subsequent to that, the browser sends a GET
https://accountinfo.corp.xxxxxxx.com.au/AIWeb/ExportAccounts/DownloadExport?OfficeId=201012249&ScheduleId=&FileFormat=CSV-Tran&IsAccountExport=False
The browser receives the file and saves it (default action).
The http response is:
(Status-Line) HTTP/1.1 200 OK
Content-Length 73
Content-Type application/AIUsers
Date Thu, 24 Dec 2015 03:24:22 GMT
p3p CP="NON CUR OTPi OUR NOR UNI"
x-frame-options SAMEORIGIN
x-aspnetmvc-version 1.0
Cache-Control private
Content-Disposition attachment; filename=Accounts_24-12-2015_91456974_T.CSV
I emulate the form submission (with ruby mechanize), wait a few seconds, and agent.get the URL above, as in:
url = "https://accountinfo.corp.westpac.com.au/AIWeb/ExportAccounts/DownloadExport?OfficeId=201012249&ScheduleId=&FileFormat=CSV-Tran&IsAccountExport=False"
download_page = agent.get(url)
The result is incorrect:
<html><body><script>window.parent.location = '/AIWeb/ExportAccounts/ShowErrorMessage?errorCode=3';</script></body></html>
Would appreciate some guidance on how to get the result of the GET.
Regards
There must be something that server expects in headers (and/or) cookies. You can check that using chrome inspector or firebug and add to your request if mechanize supports it (no idea what that is).
My question is pretty simple. Although while searching over, I have not found a simple satisfying answer.
I am using Jquery ajax request to get the data from a server. Server
hosts a rest API that sets the Etag and Cach-control headers to the GET requests. The Server also sets CORS headers to allow the Etag.
The client of the Api is a browser web app. I am using Ajax request to call the Api. Here are the response headers from server after a simple GET request:
Status Code: 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-transform, max-age=86400
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: application/json
Date: Sun, 30 Aug 2015 13:23:41 GMT
Etag: "-783704964"
Keep-Alive: timeout=15, max=99
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Vary: Accept-Encoding
access-control-allow-headers: X-Requested-With, Content-Type, Etag,Authorization
access-control-allow-methods: GET, POST, DELETE, PUT
All I want to know is:
Do I need to manually collect the Etag from response headers sent from the server and attach an if-no-match header to ajax request?OR the Browser sends it by-default in a conditional get request when it has an 'Etag'
I have done debugging over the network console in the browser and It
seems the browser is doing the conditional GET automatically and
sets the if-no-match header.
if it is right, Suppose, I created a new resource, and then I called the get request. It gives me the past cached data for the first time. But when I reload the page, It gives the updated one. So I am confused that, If the dataset on the server-side has changed and it sends a different Etag, Why doesn't the browser get an updated data set from the server unless I have to reload
Also in case of pagination. Suppose I have a URL /users?next=0. next is a query param where the value for the next changes for every new request. Since each response will get its own 'Etag'. Will the browser store the 'Etag' based on request or it just stores the lastest Etag of the previous get request, irrespective of the URL.
Well, I have somehow figured out the solution myself:
The browser sends the if-no-match header itself when it sees url had the e-tag header on a previous request. Browser saves the e-tag with respect to that URL, so it does not matter how many requests with different URLs happen.
Also, a trick to force the browser to fetch a conditional-get to check the e-tag:
Set the max-age header to the lowest (for me 60s works great)
once the cache expires, thebrowser will send a conditional-get to check if the expired cached resource is valid. If the if-no-match header matches with e-tag. The server sends the response back with 304: Not-Modified header. This means the expired cached resource is valid and can be used.
My server returns the following headers for a file:
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:155
Content-Type:text/css
Date:Thu, 06 Feb 2014 18:32:44 GMT
ETag:"99000000061b06-9b-4f1c118fdd2f1"
Keep-Alive:timeout=5, max=100
Last-Modified:Thu, 06 Feb 2014 18:32:37 GMT
As you can see, it doesn't return cache-control header, however it returns ETag and Last-Modified headers.
My question is whether browser is going to cache the requested file? I can observr that during the following requests the browser sends ETag:"99000000061b06-9b-4f1c118fdd2f1" in headers and server returns status code 304.
And second question: Will browser cache resource and request it with ETag if Cache-control is set to no-cache?
For first part of question - It is up to your browser (its implementation and configuration) if the response will be cached and when will be revalidated. The only (standardized) difference between browser behaviour with validation headers and behaviour without validation headers is that former one can reduce traffic with server using validation.
Second question: Yes. Browser will cache resource but every time you open the page browser will ask origin server if resource was not modified. If not modified server will respond 304 and browser will display cached content. Otherwise server will send new content.
My guess would be ETag can serve as cache-control: no-cache.
In my django app I want to both render a template and invoke the browser's save as. I’ve implemented this using ajax – I have a view that renders a template. In that template is some javascript that invokes another view with ajax. That view returns a response that should trigger the save as. But when returned from the ajax invoked view it does not. If I invoke the same view by cutting and pasting the URL generated by the ajax call into my browser’s address bar the save as is invoked, but when called from ajax it is not. I have verified from the python side using pdb that the view is invoked and the proper response is being returned. I have verified from the browser side that it received the response.
This is the response I return (cut and pasted from the browser's debug window):
HTTP/1.1 200 OK
Date: Tue, 26 Mar 2013 13:07:47 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/1.0.0f DAV/2 mod_wsgi/3.3 Python/2.6.7
Vary: Cookie
Content-Disposition: Attachment; filename=SF69.xml
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml
Any idea why that could be happening? Why would this behave differenly when being returned from ajax vs. 'normal' way?