📄 mexample5.java
字号:
package net.jumperz.app.MGuardian.plugin;
import java.io.*;
import java.util.*;
import net.jumperz.net.*;
import net.jumperz.util.*;
import net.jumperz.app.MGuardian.*;
public class MExample5
extends MGuardianPlugin
{
OutputStream fo;
private static final int BUFSIZE = 200;
//--------------------------------------------------------------------------------
public void startup()
throws IOException
{
String logFileName = control.getProperty( "example5.logFileName" );
fo = new BufferedOutputStream( new FileOutputStream( logFileName, true ) );
}
//--------------------------------------------------------------------------------
public Map execute( Map sessionInfo )
throws IOException
{
MHttpRequest request = ( MHttpRequest )sessionInfo.get( "request" );
MHttpResponse response = ( MHttpResponse )sessionInfo.get( "response" );
StringBuffer strBuf = new StringBuffer( BUFSIZE );
if( response.headerExists( "Content-Type" ) )
{
strBuf.append( response.getHeaderValue( "Content-Type" ) );
}
strBuf.append( ":" );
if( request.headerExists( "Host" ) )
{
strBuf.append( request.getHeaderValue( "Host" ) );
}
strBuf.append( ":" );
strBuf.append( request.getUri() );
strBuf.append( ":" );
strBuf.append( response.getStatusCode() );
strBuf.append( "\r\n" );
synchronized( fo )
{
fo.write( strBuf.toString().getBytes( MCharset.CS_ISO_8859_1 ) );
}
return null;
}
//--------------------------------------------------------------------------------
public void shutdown()
{
try
{
fo.flush();
fo.close();
}
catch( Exception e )
{
e.printStackTrace();
}
}
//--------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -