• How to set a default custom HTTP response code (HttpCustomResponseCode)

    This HTTP Provider for Wowza Streaming Engine™ media server software replaces the default HTTP Provider and will return 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


    You can't configure HTTP Providers in Wowza Streaming Engine Manager, so you must edit the VHost.xml file in a text editor to change the 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.


    Originally Published: For Wowza Streaming Engine on 01-06-2015.
    Updated: 04-14-2016.

    If you're having problems or want to discuss this article, post in our forum.