Set a default custom HTTP response code using the Wowza Streaming Engine Java API

This HTTP provider for Wowza Streaming Engine™ media server software (HttpCustomResponseCode) replaces the default HTTP provider and returns a custom HTTP response code for requests that aren't handled previously. Only the response headers are returned. No content or HTTP body is returned.

Note: The default HTTP provider normally returns the Wowza Streaming Engine software version.
package com.wowza.wms.example;

import com.wowza.wms.http.*;
import com.wowza.wms.vhost.*;

public class HttpCustomResponseCode extends HTTProvider2Base
{

	public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp)
	{
		if (!doHTTPAuthentication(vhost, req, resp))
			return;
		int responseCode = this.properties.getPropertyInt("responseCode", 200);
		resp.setResponseCode(responseCode);
	}
}

Configuration


  1. Open the Wowza Streaming Engine VHost.xml configuration file [install-dir]/conf/VHost.xml in a text editor.
     
  2. In VHost.xml, locate the default streaming hostport (<HostPortList>/<HostPort>/<Name>Default Streaming</Name>).
     
  3. In this section of the XML file, in the list of HTTP providers (<HTTPProviders>...</HTTPProviders>, locate the following HTTP provider configuration section (this is the default HTTP provider):
    <HTTPProvider>
    	<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
    	<RequestFilters>*</RequestFilters>
    	<AuthenticationMethod>none</AuthenticationMethod>
    </HTTPProvider>
  4. Replace this HTTP provider with the following:
    <HTTPProvider>
    	<BaseClass>com.wowza.wms.example.HttpCustomResponseCode</BaseClass>
    	<RequestFilters>*</RequestFilters>
    	<AuthenticationMethod>none</AuthenticationMethod>
    	<Properties>
    		<Property>
    			<Name>responseCode</Name>
    			<Value>404</Value>
    		</Property>
    	</Properties>
    </HTTPProvider>

    You can set the responseCode property value to any valid HTTP response status code.
     
  5. Save the VHost.xml file, and then restart Wowza Streaming Engine.