msslredirector.java

来自「httptunnel.jar httptunnel java 源码」· Java 代码 · 共 47 行

JAVA
47
字号
package net.jumperz.app.MGuardian.plugin;

import net.jumperz.net.*;
import net.jumperz.util.*;
import java.net.*;
import java.util.*;
import java.io.*;

public class MSslRedirector
extends MGuardianPlugin
{
//--------------------------------------------------------------------------------
public Map execute( Map sessionInfo )
throws IOException
{
MHttpResponse response = ( MHttpResponse )sessionInfo.get( "response" );
if( response == null )
	{
	return null;
	}
String protocol = ( String )sessionInfo.get( "protocol" );
if( !protocol.equals( "HTTPS" ) )
	{
	return null;
	}
int statusCode = response.getStatusCode();
if( statusCode < 300 || 400 <= statusCode )
	{
	return null;
	}

if( !response.headerExists( "Location" ) )
	{
	return null;
	}

String location = response.getHeaderValue( "Location" );
if( location.indexOf( "http://" ) == 0 )
	{
	location = location.replaceFirst( "^http", "https" );
	response.setHeaderValue( "Location", location );
	}

return null;
}
//--------------------------------------------------------------------------------
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?