@ -35,11 +35,11 @@ import de.anomic.server.serverByteBuffer;
public class httpSSI {
public static void writeSSI ( serverByteBuffer in , OutputStream out , String authorization ) throws IOException {
writeSSI ( in , 0 , out , authorization );
public static void writeSSI ( serverByteBuffer in , OutputStream out , String authorization , String requesthost ) throws IOException {
writeSSI ( in , 0 , out , authorization , requesthost );
}
public static void writeSSI ( serverByteBuffer in , int off , OutputStream out , String authorization ) throws IOException {
public static void writeSSI ( serverByteBuffer in , int off , OutputStream out , String authorization , String requesthost ) throws IOException {
int p = in . indexOf ( "<!--#" . getBytes ( ) , off ) ;
if ( p > = 0 ) {
int q = in . indexOf ( "-->" . getBytes ( ) , p + 10 ) ;
@ -48,8 +48,8 @@ public class httpSSI {
} else {
out . write ( in . getBytes ( off , p - off ) ) ;
}
parseSSI ( in , p , q + 3 - p , out , authorization );
writeSSI ( in , q + 3 , out , authorization );
parseSSI ( in , p , q + 3 - p , out , authorization , requesthost );
writeSSI ( in , q + 3 , out , authorization , requesthost );
} else /* p < 0 */ {
if ( out instanceof httpChunkedOutputStream ) {
( ( httpChunkedOutputStream ) out ) . write ( in , off , in . length ( ) - off ) ;
@ -59,17 +59,17 @@ public class httpSSI {
}
}
private static void parseSSI ( serverByteBuffer in , int off , int len , OutputStream out , String authorization ) {
private static void parseSSI ( serverByteBuffer in , int off , int len , OutputStream out , String authorization , String requesthost ) {
if ( in . startsWith ( "<!--#include virtual=\"" . getBytes ( ) , off ) ) {
int q = in . indexOf ( "\"" . getBytes ( ) , off + 22 ) ;
if ( q > 0 ) {
String path = in . toString ( off + 22 , q ) ;
writeContent ( path , out , authorization );
writeContent ( path , out , authorization , requesthost );
}
}
}
private static void writeContent ( String path , OutputStream out , String authorization ) {
private static void writeContent ( String path , OutputStream out , String authorization , String requesthost ) {
// check if there are arguments in path string
String args = "" ;
int argpos = path . indexOf ( '?' ) ;
@ -85,7 +85,7 @@ public class httpSSI {
conProp . setProperty ( httpHeader . CONNECTION_PROP_PATH , path ) ;
conProp . setProperty ( httpHeader . CONNECTION_PROP_ARGS , args ) ;
conProp . setProperty ( httpHeader . CONNECTION_PROP_HTTP_VER , httpHeader . HTTP_VERSION_0_9 ) ;
conProp . setProperty ( httpHeader . CONNECTION_PROP_CLIENTIP , "127.0.0.1" ) ;
conProp . setProperty ( httpHeader . CONNECTION_PROP_CLIENTIP , requesthost ) ;
header . put ( httpHeader . AUTHORIZATION , authorization ) ;
httpdFileHandler . doGet ( conProp , header , out ) ;
}