Setting up third party modules for HTTP Server

This topic provides information about how to set up third party modules for your Web server.

The HTTP Server can extend its functionality in specific areas of your server using modules. For example, a module could be configured to create a new type of authentication that is not available with the shipped HTTP Server. The Apache Software Foundation (ASF) Link outside Information Center provides basic information for writing your own modules. Before the module can be used by your HTTP Server, it must be compiled and saved in the QSYS directory. In addition, the LoadModule directive must be entered in your server configuration file along with any specific context required information.

As of 5.4, modules must be recompiled with a UTF locale. This creates an environment where locale-dependent C runtime functions assume that string data is encoded in UTF-8. Any hardcoded constants can be encoded in UTF-8 by adding a #pragma convert(1208) statement in the module. Additionally, input data from the client will no longer be converted to EBCDIC but will be passed as-is. Output data sent from the module is not converted either so it must be encoded in ASCII or UTF8 as required. APR and HTTP APIs as of V5R4, expect data in UTF-8. Note that several APIs have additional functions that allow a CCSID to be set to indicate the encoding of the parameters being passed. Conversion functions between UTF-8 and EBCDIC have been added. Be sure to review APIs used by your module to be aware of current changes.

Follow the below directions to compile and use a new module.

1. Save the source code

Save the source code in your QSYS or IFS directory. All objects created from compiling and creating the service program must be placed in the QSYS directory.

2. Compile the source code

Compile the source code using the CRTCMOD command. Before you compile the program, make sure you have the correct programming language compiler installed on your server (the most common programming language used is C). Replace the text in the parenthesis ( ) with your own information.

CRTCMOD MODULE(Destination module name and library for the compiled module object.) 
Any Apache modules will need to be changed in order to run as a UTF-8 based server module as opposed to an EBCDIC based server module.
  • For ILE C use:
    CRTCMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c')
    DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES)
    INCDIR('/qibm/proddata/httpa/include')
  • For C++ use:
    CRTCPPMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c') 
    DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES) 
    INCDIR('/qibm/proddata/httpa/include') 
Notice the change in the LOCALETYPE parameter. Using LOCALETYPE(*LOCALEUTF) does the following: Program objects created with this option use the locale support provided by *LOCALE objects. Wide-character types contain four-byte UTF-32 values. Narrow character types contain UTF-8 values. The effect of this change enables the locale dependent C runtime functions to work on UTF-8 strings. See WebSphere® Development Studio: ILE C/C++ Programmer's Guide for more information.

Correct any errors found while compiling. Continue to compile the source code until there are no errors. Save the compiled module in the QSYS directory.

3. Create a service program

Create a service program using the CRTSRVPGM command. Replace the text in the parenthesis ( ) with your own information.

CRTSRVPGM SRVPGM(Destination service program name and library.) 
   MODULE(Module or modules to be built into the service program. Same as CRTCMOD above.) 
   EXPORT(Name of the data item to be exported.) 
   BNDSRVPGM(Specifies other service programs needed to bind to when creating the service program.)
Note: The EXPORT field can only have the value of either *ALL or *SRCFILE. If *SRCFILE is used, you will need to have an export source file defining which data items or procedures need to be exported and contain the name of the module structure (for example, cgi_module).

The BNDSRVPGM field must have, at a minimum, the following: (QHTTPSVR/QZSRAPR QHTTPSVR/QZSRCORE QHTTPSVR/QZSRXMLP QHTTPSVR/QZSRSDBM ). These values will cover all the HTTP Sever APIs that may be used when building the service program.

4. Add LoadModule to HTTP Server configuration file

See Setting up Apache modules for the steps you need to perform to add the LoadModule directive.

Note: Some third-party modules designed for previous IBM® i releases may require code changes due to the API changes of new 2.4 version HTTP Server for i. All third-party modules are required to be recompiled against the new 2.4 version HTTP server runtime . For the API update plase refer to API update for detail information.