/*
* @(#)FCGIMessage.java
*
*
* FastCGi compatibility package Interface
*
*
* Copyright (c) 1996 Open Market, Inc.
*
* See the file "LICENSE.TERMS" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* $Id: FCGIMessage.java,v 1.4 2000/10/02 15:09:07 robs Exp $
*/
package com.fastcgi;
import java.io.*;
import java.util.Properties;
/* This class handles reading and building the fastcgi messages.
* For reading incoming mesages, we pass the input
* stream as a param to the constructor rather than to each method.
* Methods that build messages use and return internal buffers, so they
* dont need a stream.
*/
public class FCGIMessage
{
private static final String RCSID = "$Id: FCGIMessage.java,v 1.4 2000/10/02 15:09:07 robs Exp $";
/*
* Instance variables
*/
/*
* FCGI Message Records
* The logical structures of the FCGI Message Records.
* Fields are originally 1 unsigned byte in message
* unless otherwise noted.
*/
/*
* FCGI Header
*/
private int h_version;
private int h_type;
private int h_requestID; // 2 bytes
private int h_contentLength; // 2 bytes
private int h_paddingLength;
/*
* FCGI BeginRequest body.
*/
private int br_role; // 2 bytes
private int br_flags;
private FCGIInputStream in;
/*
* constructor - Java would do this implicitly.
*/
public FCGIMessage(){
super();
}
/*
* constructor - get the stream.
*/
public FCGIMessage(FCGIInputStream instream){
in = instream;
}
/*
* Message Reading Methods
*/
/*
* Interpret the FCGI Message Header. Processes FCGI
* BeginRequest and Management messages. Param hdr is the header.
* The calling routine has to keep track of the stream reading
* management or use FCGIInputStream.fill() which does just that.
*/
public int processHeader(byte[] hdr) throws IOException{
processHeaderBytes(hdr);
if (h_version != FCGIGlobalDefs.def_FCGIVersion1) {
return(FCGIGlobalDefs.def_FCGIUnsupportedVersion);
}
in.contentLen = h_contentLength;
in.paddingLen = h_paddingLength;
if (h_type == FCGIGlobalDefs.def_FCGIBeginRequest) {
return processBeginRecord(h_requestID);
}
if (h_requestID == FCGIGlobalDefs.def_FCGINullRequestID) {
return processManagementRecord(h_type);
}
if (h_requestID != in.request.requestID) {
return(FCGIGlobalDefs.def_FCGISkip);
}
if (h_type != in.type) {
return(FCGIGlobalDefs.def_FCGIProtocolError);
}
return(FCGIGlobalDefs.def_FCGIStreamRecord);
}
/* Put the unsigned bytes in the incoming FCGI header into
* integer form for Java, concatinating bytes when needed.
* Because Java has no unsigned byte type, we have to be careful
* about signed numeric promotion to int.
*/
private void processHeaderBytes(byte[] hdrBuf){
h_version = hdrBuf[0] & 0xFF;
h_type = hdrBuf[1] & 0xFF;
h_requestID = ((hdrBuf[2] & 0xFF) << 8) | (hdrBuf[3] & 0xFF);
h_contentLength = ((hdrBuf[4] & 0xFF) << 8) | (hdrBuf[5] & 0xFF);
h_paddingLength = hdrBuf[6] & 0xFF;
}
/*
* Reads FCGI Begin Request Record.
*/
public int processBeginRecord(int requestID) throws IOException {
byte beginReqBody[];
byte endReqMsg[];
if (requestID == 0 || in.contentLen
!= FCGIGlobalDefs.def_FCGIEndReqBodyLen) {
return FCGIGlobalDefs.def_FCGIProtocolError;
}
/*
* If the webserver is multiplexing the connection,
* this library can't deal with it, so repond with
* FCGIEndReq message with protocolStatus FCGICantMpxConn
*/
if (in.request.isBeginProcessed) {
endReqMsg = new byte[FCGIGlobalDefs.def_FCGIHeaderLen
+ FCGIGlobalDefs.def_FCGIEndReqBodyLen];
System.arraycopy(makeHeader(
FCGIGlobalDefs.def_FCGIEndRequest,
requestID,
FCGIGlobalDefs.def_FCGIEndReqBodyLen,
0), 0, endReqMsg, 0,
FCGIGlobalDefs.def_FCGIHeaderLen);
System.arraycopy(makeEndrequestBody(0,
FCGIGlobalDefs.def_FCGICantMpxConn), 0,
endReqMsg,
FCGIGlobalDefs.def_FCGIHeaderLen,
FCGIGlobalDefs.def_FCGIEndReqBodyLen);
/*
* since isBeginProcessed is first set below,this
* can't be out first call, so request.out is properly set
*/
try {
in.request.outStream.write(endReqMsg, 0,
FCGIGlobalDefs.def_FCGIHeaderLen
+ FCGIGlobalDefs.def_FCGIEndReqBodyLen);
} catch (IOException e){
in.request.outStream.setException(e);
return -1;
}
}
/*
* Accept this new request. Read the record body
*/
in.request.requestID = requestID;
beginReqBody =
new byte[FCGIGlobalDefs.def_FCGIBeginReqBodyLen];
if (in.read(beginReqBody, 0,
FCGIGlobalDefs.def_FCGIBeginReqBodyLen) !=
FCGIGlobalDefs.def_FCGIBeginReqBodyLen) {
return FCGIGlobalDefs.def_FCGIProtocolError;
}
br_flags = beginReqBody[2] & 0xFF;
in.request.keepConnection
= (br_flags & FCGIGlobalDefs.def_FCGIKeepConn) != 0;
br_role = ((beginReqBody[0] & 0xFF) << 8) | (beginReqBody[1] & 0xFF);
in.request.role = br_role;
in.request.isBeginProcessed = true;
return FCGIGlobalDefs.def_FCGIBeginRecord;
}
/*
* Reads and Responds to a Management Message. The only type of
* management message this library understands is FCGIGetValues.
* The only variables that this library's FCGIGetValues understands
* are def_FCGIMaxConns, def_FCGIMaxReqs, and def_FCGIMpxsConns.
* Ignore the other management variables, and repsond to other
* management messages with FCGIUnknownType.
*/
public int processManagementRecord(int type) throws IOException {
byte[] response = new byte[64];
int wrndx = response[FCGIGlobalDefs.def_FCGIHeaderLen];
int value, len, plen;
if (type == FCGIGlobalDefs.def_FCGIGetValues) {
Properties tmpProps = new Properties();
readParams(tmpProps);
if (in.getFCGIError() != 0 || in.contentLen != 0) {
return FCGIGlobalDefs.def_FCGIProtocolError;
}
if (tmpProps.containsKey(
FCGIGlobalDefs.def_FCGIMaxConns)) {
makeNameVal(
FCGIGlobalDefs.def_FCGIMaxConns, "1",
response, wrndx);
}
else {
if (tmpProps.containsKey(
FCGIGlobalDefs.def_FCGIMaxReqs)) {
makeNameVal(
FCGIGlobalDefs.def_FCGIMaxReqs, "1",
response, wrndx);
}
else {
if (tmpProps.containsKey(
FCGIGlobalDefs.def_FCGIMaxConns)) {
makeNameVal(
FCGIGlobalDefs.def_FCGIMpxsConns, "0",
response, wrndx);
}
}
}
plen = 64 - wrndx;
len = wrndx - FCGIGlobalDefs.def_FCGIHeaderLen;
System.arraycopy(makeHeader(
FCGIGlobalDefs.def_FCGIGetValuesResult,
FCGIGlobalDefs.def_FCGINullRequestID,
len, plen), 0,
response, 0,
FCGIGlobalDefs.def_FCGIHeaderLen);
}
else {
ple
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共123个文件
htm:14个
gif:14个
c:11个
http://blog.csdn.net/wangkangluo1/archive/2011/05/11/6411641.aspx [原创] Redhat 上 FastCGI 安装与配置 软件包 相关软件包: httpd httpd-devel fcgi-2.4.0.tar.gz mod_fastcgi-2.4.6.tar.gz 请仔细阅读其中的README 配置httpd.conf: LoadModule fastcgi_module modules/mod_fastcgi.so <IfModule fastcgi_module> AddHandler fastcgi-script .fcgi # you can put whatever extension you want </IfModule> FastCgiIpcDir /tmp FastCgiServer /home/m/Dev/cvs/ImRoBot5/shdaily/cgi/shdaily.fcgi -processes 1 -idle-timeout 1000
资源推荐
资源详情
资源评论
收起资源包目录
fcgi-2.4.0.tar.gz (123个子文件)
cgi-fcgi.1 4KB
FCGI_Accept.3 5KB
FCGI_StartFilterData.3 2KB
FCGI_Finish.3 1KB
FCGI_SetExitStatus.3 828B
Makefile.am 4KB
Makefile.am 1KB
Makefile.am 880B
Makefile.am 393B
Makefile.am 155B
fcgiapp.c 70KB
os_win32.c 47KB
os_unix.c 32KB
cgi-fcgi.c 24KB
fcgi_stdio.c 20KB
log-dump.c 4KB
echo-x.c 2KB
threaded.c 2KB
echo.c 2KB
authorizer.c 1KB
size.c 851B
ChangeLog 7KB
compile 3KB
configure 285KB
configure 91KB
echo-cpp.cpp 6KB
fcgio.cpp 4KB
depcomp 12KB
libfcgi.dsp 5KB
logdump.dsp 4KB
authorizer.dsp 4KB
echo-cpp.dsp 4KB
echox.dsp 4KB
threaded.dsp 4KB
cgifcgi.dsp 4KB
echo.dsp 4KB
size.dsp 4KB
FastCGI.dsw 3KB
covera.gif 41KB
ch1inta1.gif 7KB
ch1intra.gif 6KB
img00001.gif 4KB
img00003.gif 4KB
img00002.gif 2KB
navbar.gif 2KB
aplib-hd.gif 2KB
serv-hd.gif 2KB
words-hd.gif 2KB
mail-hd.gif 2KB
fcgi-hd.gif 1KB
omi-logo.gif 217B
divider.gif 159B
config.guess 37KB
fcgiapp.h 18KB
fcgi_stdio.h 6KB
fcgio.h 4KB
fcgios.h 3KB
fcgi_config.h 3KB
fastcgi.h 3KB
fcgi_config_x86.h 930B
fcgimisc.h 638B
fastcgi.htm 38KB
fcgi-devel-kit.htm 32KB
ch1intro.htm 24KB
fcgi-perf.htm 22KB
fcgi-java.htm 20KB
fcgi-tcl.htm 15KB
ch2c.htm 13KB
apaman.htm 9KB
ap_guida.htm 9KB
ap_guide.htm 7KB
ch3perl.htm 5KB
cover.htm 4KB
ch4tcl.htm 4KB
fcgi-perl.htm 2KB
fcgi-spec.html 57KB
www5-api-workshop.html 13KB
overview.html 5KB
Makefile.in 18KB
Makefile.in 16KB
Makefile.in 15KB
Makefile.in 10KB
Makefile.in 7KB
fcgi_config.h.in 3KB
configure.in 3KB
fcgi_config.h.in 2KB
configure.in 369B
stamp-h.in 0B
install-sh 5KB
FCGIMessage.java 14KB
FCGIInputStream.java 11KB
FCGIOutputStream.java 9KB
FCGIInterface.java 8KB
FCGIGlobalDefs.java 3KB
FCGIRequest.java 2KB
aclocal.m4 146KB
aclocal.m4 17KB
acinclude.m4 14KB
libfcgi.mak 7KB
echo-cpp.mak 4KB
共 123 条
- 1
- 2
wangkangluo1
- 粉丝: 0
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页