зеркало из https://github.com/mozilla/pjs.git
Some test changes to allow echoing requests at arbitrary locations in urlmap. You can now use ECHO [HTTPHeader] to display all headers (if HTTPHeader is not specified) or that header value as it came in the request. See <your-testserver>/echo for an example. Not in build (a=leaf)
This commit is contained in:
Родитель
988b8d4cc1
Коммит
382ede1d1b
|
@ -37,5 +37,5 @@ include $(topsrcdir)/config/rules.mk
|
|||
# Hack rule, this probably needs to be changed
|
||||
# to something official. Works on Solaris for me. -mcafee
|
||||
install::
|
||||
javac $(JSRCS)
|
||||
javac -deprecation $(JSRCS)
|
||||
|
||||
|
|
|
@ -123,6 +123,28 @@ class ScriptFile {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (s.startsWith("ECHO")) {
|
||||
outDirty = true;
|
||||
boolean parameter = false;
|
||||
try {
|
||||
String header = new String(s.substring(5));
|
||||
String req= new String(con.request);
|
||||
int t = req.indexOf(header);
|
||||
if (t != -1) {
|
||||
out.println(req.substring(
|
||||
t, req.indexOf("\n", t)));
|
||||
parameter = true;
|
||||
}
|
||||
else {
|
||||
out.println("Error: " + header +
|
||||
" not specified in request!");
|
||||
}
|
||||
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e) {}
|
||||
if (!parameter)
|
||||
out.println(con.request);
|
||||
}
|
||||
else if (s.startsWith("INCLUDE")) {
|
||||
outDirty = true;
|
||||
WriteOutFile("docs/" + s.substring(8));
|
||||
|
|
|
@ -120,7 +120,7 @@ CRLF
|
|||
END
|
||||
|
||||
#
|
||||
#
|
||||
# Post example...
|
||||
#
|
||||
START /post
|
||||
INCLUDE generic.res
|
||||
|
@ -129,3 +129,23 @@ CRLF
|
|||
INCLUDE post.html
|
||||
END
|
||||
|
||||
#
|
||||
# Do other stuff with echoing the request as well...
|
||||
#
|
||||
START /echo
|
||||
INCLUDE generic.res
|
||||
Content-Type: text/html
|
||||
CRLF
|
||||
<HTML>
|
||||
<H2>Echo request example</H2>
|
||||
<HR>
|
||||
This should echo all the request headers-<BR>
|
||||
<PRE>
|
||||
ECHO
|
||||
</PRE>
|
||||
<HR>
|
||||
This should echo only the user-agent header- (this is case sensitive!)<BR>
|
||||
<PRE>
|
||||
ECHO User-Agent
|
||||
</PRE>
|
||||
END
|
||||
|
|
|
@ -37,5 +37,5 @@ include $(topsrcdir)/config/rules.mk
|
|||
# Hack rule, this probably needs to be changed
|
||||
# to something official. Works on Solaris for me. -mcafee
|
||||
install::
|
||||
javac $(JSRCS)
|
||||
javac -deprecation $(JSRCS)
|
||||
|
||||
|
|
|
@ -123,6 +123,28 @@ class ScriptFile {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (s.startsWith("ECHO")) {
|
||||
outDirty = true;
|
||||
boolean parameter = false;
|
||||
try {
|
||||
String header = new String(s.substring(5));
|
||||
String req= new String(con.request);
|
||||
int t = req.indexOf(header);
|
||||
if (t != -1) {
|
||||
out.println(req.substring(
|
||||
t, req.indexOf("\n", t)));
|
||||
parameter = true;
|
||||
}
|
||||
else {
|
||||
out.println("Error: " + header +
|
||||
" not specified in request!");
|
||||
}
|
||||
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e) {}
|
||||
if (!parameter)
|
||||
out.println(con.request);
|
||||
}
|
||||
else if (s.startsWith("INCLUDE")) {
|
||||
outDirty = true;
|
||||
WriteOutFile("docs/" + s.substring(8));
|
||||
|
|
|
@ -120,7 +120,7 @@ CRLF
|
|||
END
|
||||
|
||||
#
|
||||
#
|
||||
# Post example...
|
||||
#
|
||||
START /post
|
||||
INCLUDE generic.res
|
||||
|
@ -129,3 +129,23 @@ CRLF
|
|||
INCLUDE post.html
|
||||
END
|
||||
|
||||
#
|
||||
# Do other stuff with echoing the request as well...
|
||||
#
|
||||
START /echo
|
||||
INCLUDE generic.res
|
||||
Content-Type: text/html
|
||||
CRLF
|
||||
<HTML>
|
||||
<H2>Echo request example</H2>
|
||||
<HR>
|
||||
This should echo all the request headers-<BR>
|
||||
<PRE>
|
||||
ECHO
|
||||
</PRE>
|
||||
<HR>
|
||||
This should echo only the user-agent header- (this is case sensitive!)<BR>
|
||||
<PRE>
|
||||
ECHO User-Agent
|
||||
</PRE>
|
||||
END
|
||||
|
|
Загрузка…
Ссылка в новой задаче