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:
gagan%netscape.com 2000-04-07 23:14:52 +00:00
parent 9ad9804e66
commit 8429a748bc
6 changed files with 88 additions and 4 deletions

View File

@ -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)

View File

@ -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));

View File

@ -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

View File

@ -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)

View File

@ -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));

View File

@ -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