Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
09154c61
Commit
09154c61
authored
Jan 27, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spdycat, spdyd: Color verbose output
parent
964c0d10
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
12 deletions
+70
-12
src/spdycat.cc
src/spdycat.cc
+2
-0
src/spdyd.cc
src/spdyd.cc
+3
-0
src/spdylay_ssl.cc
src/spdylay_ssl.cc
+61
-12
src/spdylay_ssl.h
src/spdylay_ssl.h
+4
-0
No files found.
src/spdycat.cc
View file @
09154c61
...
...
@@ -1028,6 +1028,8 @@ int main(int argc, char **argv)
}
}
set_color_output
(
isatty
(
fileno
(
stdout
)));
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
act
.
sa_handler
=
SIG_IGN
;
...
...
src/spdyd.cc
View file @
09154c61
...
...
@@ -173,6 +173,9 @@ int main(int argc, char **argv)
if
(
config
.
htdocs
.
empty
())
{
config
.
htdocs
=
"./"
;
}
set_color_output
(
isatty
(
fileno
(
stdout
)));
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
act
.
sa_handler
=
SIG_IGN
;
...
...
src/spdylay_ssl.cc
View file @
09154c61
...
...
@@ -475,12 +475,37 @@ void print_frame_attr_indent()
}
}
// namespace
namespace
{
bool
color_output
=
false
;
}
// namespace
void
set_color_output
(
bool
f
)
{
color_output
=
f
;
}
namespace
{
const
char
*
ansi_esc
(
const
char
*
code
)
{
return
color_output
?
code
:
""
;
}
}
// namespace
namespace
{
const
char
*
ansi_escend
()
{
return
color_output
?
"
\033
[0m"
:
""
;
}
}
// namespace
void
print_nv
(
char
**
nv
)
{
int
i
;
for
(
i
=
0
;
nv
[
i
];
i
+=
2
)
{
print_frame_attr_indent
();
printf
(
"%s: %s
\n
"
,
nv
[
i
],
nv
[
i
+
1
]);
printf
(
"%s%s%s: %s
\n
"
,
ansi_esc
(
"
\033
[1;34m"
),
nv
[
i
],
ansi_escend
(),
nv
[
i
+
1
]);
}
}
...
...
@@ -488,7 +513,10 @@ void print_timer()
{
timeval
tv
;
get_timer
(
&
tv
);
printf
(
"[%3ld.%03ld]"
,
tv
.
tv_sec
,
tv
.
tv_usec
/
1000
);
printf
(
"%s[%3ld.%03ld]%s"
,
ansi_esc
(
"
\033
[33m"
),
tv
.
tv_sec
,
tv
.
tv_usec
/
1000
,
ansi_escend
());
}
namespace
{
...
...
@@ -499,10 +527,26 @@ void print_ctrl_hd(const spdylay_ctrl_hd& hd)
}
}
// namespace
enum
print_type
{
PRINT_SEND
,
PRINT_RECV
};
namespace
{
const
char
*
frame_name_ansi_esc
(
print_type
ptype
)
{
return
ansi_esc
(
ptype
==
PRINT_SEND
?
"
\033
[1;35m"
:
"
\033
[1;36m"
);
}
}
// namespace
namespace
{
void
print_frame
(
spdylay_frame_type
type
,
spdylay_frame
*
frame
)
void
print_frame
(
print_type
ptype
,
spdylay_frame_type
type
,
spdylay_frame
*
frame
)
{
printf
(
"%s frame "
,
ctrl_names
[
type
-
1
]);
printf
(
"%s%s%s frame "
,
frame_name_ansi_esc
(
ptype
),
ctrl_names
[
type
-
1
],
ansi_escend
());
print_ctrl_hd
(
frame
->
syn_stream
.
hd
);
switch
(
type
)
{
case
SPDYLAY_SYN_STREAM
:
...
...
@@ -564,7 +608,7 @@ void on_ctrl_recv_callback
{
print_timer
();
printf
(
" recv "
);
print_frame
(
type
,
frame
);
print_frame
(
PRINT_RECV
,
type
,
frame
);
fflush
(
stdout
);
}
...
...
@@ -608,7 +652,7 @@ void on_invalid_ctrl_recv_callback
{
print_timer
();
printf
(
" [INVALID; status=%s] recv "
,
strstatus
(
status_code
));
print_frame
(
type
,
frame
);
print_frame
(
PRINT_RECV
,
type
,
frame
);
fflush
(
stdout
);
}
...
...
@@ -634,7 +678,10 @@ void on_ctrl_recv_parse_error_callback(spdylay_session *session,
int
error_code
,
void
*
user_data
)
{
print_timer
();
printf
(
" [PARSE_ERROR] recv %s frame
\n
"
,
ctrl_names
[
type
-
1
]);
printf
(
" [PARSE_ERROR] recv %s%s%s frame
\n
"
,
frame_name_ansi_esc
(
PRINT_RECV
),
ctrl_names
[
type
-
1
],
ansi_escend
());
print_frame_attr_indent
();
printf
(
"Error: %s
\n
"
,
spdylay_strerror
(
error_code
));
dump_header
(
head
,
headlen
);
...
...
@@ -660,14 +707,16 @@ void on_ctrl_send_callback
{
print_timer
();
printf
(
" send "
);
print_frame
(
type
,
frame
);
print_frame
(
PRINT_SEND
,
type
,
frame
);
fflush
(
stdout
);
}
namespace
{
void
print_data_frame
(
uint8_t
flags
,
int32_t
stream_id
,
int32_t
length
)
void
print_data_frame
(
print_type
ptype
,
uint8_t
flags
,
int32_t
stream_id
,
int32_t
length
)
{
printf
(
"DATA frame (stream_id=%d, flags=%d, length=%d)
\n
"
,
printf
(
"%sDATA%s frame (stream_id=%d, flags=%d, length=%d)
\n
"
,
frame_name_ansi_esc
(
ptype
),
ansi_escend
(),
stream_id
,
flags
,
length
);
}
}
// namespace
...
...
@@ -678,7 +727,7 @@ void on_data_recv_callback
{
print_timer
();
printf
(
" recv "
);
print_data_frame
(
flags
,
stream_id
,
length
);
print_data_frame
(
PRINT_RECV
,
flags
,
stream_id
,
length
);
fflush
(
stdout
);
}
...
...
@@ -688,7 +737,7 @@ void on_data_send_callback
{
print_timer
();
printf
(
" send "
);
print_data_frame
(
flags
,
stream_id
,
length
);
print_data_frame
(
PRINT_SEND
,
flags
,
stream_id
,
length
);
fflush
(
stdout
);
}
...
...
src/spdylay_ssl.h
View file @
09154c61
...
...
@@ -159,6 +159,10 @@ enum {
uint8_t
get_ssl_io_demand
(
SSL
*
ssl
,
ssize_t
r
);
// Setting true will print characters with ANSI color escape codes
// when printing SPDY frames. This function changes a static variable.
void
set_color_output
(
bool
f
);
}
// namespace spdylay
#endif // SPDYLAY_SSL_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment