Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ensure content is ready before serving

  • Loading branch information...
commit 72b15ad99beb9b945593c695b802fbb90a583c1c 1 parent 874b030
@benvanik authored
Showing with 12 additions and 1 deletion.
  1. +2 −0  README.md
  2. +6 −1 lib/api.js
  3. +4 −0 lib/content.js
View
2  README.md
@@ -44,6 +44,8 @@ If launching directly via `trampoline`:
### Content API
+NOTE: content status readyToPlay must be true before attempting playback!
+
Setup a new content serving request:
POST /content/setup
View
7 lib/api.js
@@ -132,7 +132,12 @@ API.prototype.dispatchContentRequest = function(req, requestBody, res) {
var actionName = contentMatch[2] || 'default';
if (actionName == 'default') {
if (req.method == 'GET') {
- content.get(req, res);
+ if (content.isReady()) {
+ content.get(req, res);
+ } else {
+ res.writeHead(500, 'Content Not Ready');
+ res.end();
+ }
} else if (req.method == 'PUT') {
content.put(req, res);
} else if (req.method == 'DELETE') {
View
4 lib/content.js
@@ -47,6 +47,10 @@ Content.prototype.matches = function(source, target) {
return sourceMatches && targetMatches;
};
+Content.prototype.isReady = function() {
+ return this.readyToPlay_;
+};
+
Content.prototype.createRemoteRequest_ = function(method, headers, callback) {
var source = this.source;
var sourceUrl = url.parse(source.content);
Please sign in to comment.
Something went wrong with that request. Please try again.