divide output into request and response sections with headings

git-svn-id: svn://10.0.0.236/trunk@168809 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
erik%vanderpoel.org
2005-02-04 20:11:34 +00:00
parent d735a1ee24
commit f47b4719a5
4 changed files with 24 additions and 6 deletions

View File

@@ -384,8 +384,8 @@ main(int argc, char *argv[])
if (url && (*url))
{
fprintf(view->out,
"<html><head><title>View %s</title></head><body>\n"
"<pre>", url);
"<html><head><title>View %s</title></head><body>\n",
url);
viewReport(app, "input url:");
viewReport(app, (char *) url);
viewReportHTML(app, "<hr>");
@@ -469,7 +469,7 @@ main(int argc, char *argv[])
u->scheme
);
}
fprintf(view->out, "</pre></body></html>\n");
fprintf(view->out, "</body></html>\n");
}
else
{

View File

@@ -114,6 +114,9 @@ httpReadHeaders(HTTP *http, App *app, Buf *buf, unsigned char *url,
unsigned char *value;
char *version;
viewPrintHTML(app, "<h4>Response</h4>");
viewPrintHTML(app, "<pre>");
contentType = NULL;
locationFound = 0;
@@ -379,6 +382,8 @@ httpParseStream(HTTP *http, App *app, unsigned char *url)
{
bufFree(buf);
}
viewPrintHTML(app, "</pre>");
}
static void
@@ -417,6 +422,9 @@ httpGetObject(App *app, HTTP *http, int sock)
Buf *buf;
HTTPNameValue *h;
viewPrintHTML(app, "<h4>Request</h4>");
viewPrintHTML(app, "<pre>");
buf = bufAlloc(sock);
bufMark(buf, 0);
@@ -458,6 +466,8 @@ httpGetObject(App *app, HTTP *http, int sock)
bufMark(buf, 0);
app->httpRequest(app, buf);
viewPrintHTML(app, "</pre>");
if (bufError(buf))
{
return;

View File

@@ -235,6 +235,13 @@ viewVerbose(void)
verbose = 1;
}
void
viewPrintHTML(App *app, char *str)
{
fprintf(app->view.out, "%s", str);
fflush(app->view.out);
}
void
viewReport(App *app, char *str)
{
@@ -242,8 +249,8 @@ viewReport(App *app, char *str)
if (verbose)
{
esc = escapeHTML((unsigned char *) str);
fprintf(app->view.out, "%s\n", (char *) esc);
esc = escapeHTML((unsigned char *) str);
fprintf(app->view.out, "%s\n", (char *) esc);
free(esc);
fflush(app->view.out);
}
@@ -254,7 +261,7 @@ viewReportHTML(App *app, char *str)
{
if (verbose)
{
fprintf(app->view.out, "%s\n", str);
fprintf(app->view.out, "%s\n", str);
fflush(app->view.out);
}
}

View File

@@ -43,6 +43,7 @@ void viewHTMLText(App *app, Buf *buf);
void viewHTTP(App *app, Buf *buf);
void viewHTTPHeaderName(App *app, Buf *buf);
void viewHTTPHeaderValue(App *app, Buf *buf);
void viewPrintHTML(App *app, char *str);
void viewReport(App *app, char *str);
void viewReportHTML(App *app, char *str);
void viewVerbose(void);