Added CORS headers and OPTIONS/HEAD support for HTTP internal's onFail responses.
This commit is contained in:
		
							parent
							
								
									94b8fcd2d6
								
							
						
					
					
						commit
						d944d4600e
					
				
					 1 changed files with 8 additions and 0 deletions
				
			
		| 
						 | 
					@ -61,6 +61,7 @@ namespace Mist {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  void OutHTTP::onFail(){
 | 
					  void OutHTTP::onFail(){
 | 
				
			||||||
 | 
					    std::string method = H.method;
 | 
				
			||||||
    // send logo icon
 | 
					    // send logo icon
 | 
				
			||||||
    if (H.url.length() > 4 && H.url.substr(H.url.length() - 4, 4) == ".ico"){
 | 
					    if (H.url.length() > 4 && H.url.substr(H.url.length() - 4, 4) == ".ico"){
 | 
				
			||||||
      sendIcon();
 | 
					      sendIcon();
 | 
				
			||||||
| 
						 | 
					@ -81,7 +82,14 @@ namespace Mist {
 | 
				
			||||||
        H.Clean();
 | 
					        H.Clean();
 | 
				
			||||||
        H.SetBody("if (!mistvideo){var mistvideo = {};}\nmistvideo['" + streamName + "'] = "+json_resp.toString()+";\n");
 | 
					        H.SetBody("if (!mistvideo){var mistvideo = {};}\nmistvideo['" + streamName + "'] = "+json_resp.toString()+";\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      H.setCORSHeaders();
 | 
				
			||||||
 | 
					      if(method == "OPTIONS" || method == "HEAD"){
 | 
				
			||||||
 | 
					        H.SendResponse("200", "OK", myConn);
 | 
				
			||||||
 | 
					        H.Clean();
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      H.SendResponse("200", "Stream not found", myConn);
 | 
					      H.SendResponse("200", "Stream not found", myConn);
 | 
				
			||||||
 | 
					      H.Clean();
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    INFO_MSG("Failing: %s", H.url.c_str());
 | 
					    INFO_MSG("Failing: %s", H.url.c_str());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue