Skip to content

Commit

Permalink
Header support (#92)
Browse files Browse the repository at this point in the history
* autoconf

* header support added

* header support added, missing option typo fixed

* Update slowhttptestmain.cc

better example

* man added
  • Loading branch information
tomikoski authored Oct 21, 2024
1 parent 6e316be commit 0eceeab
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 76 deletions.
2 changes: 1 addition & 1 deletion depcomp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

scriptversion=2018-03-07.03; # UTC

# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
148 changes: 80 additions & 68 deletions install-sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile

scriptversion=2018-03-11.20; # UTC
scriptversion=2020-11-14.01; # UTC

# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
Expand Down Expand Up @@ -69,6 +69,11 @@ posix_mkdir=
# Desired mode of installed file.
mode=0755

# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22

backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
Expand Down Expand Up @@ -99,18 +104,28 @@ Options:
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to [email protected].
Automake home page: https://www.gnu.org/software/automake/
"

while test $# -ne 0; do
Expand All @@ -137,8 +152,13 @@ while test $# -ne 0; do
-o) chowncmd="$chownprog $2"
shift;;

-p) cpprog="$cpprog -p";;

-s) stripcmd=$stripprog;;

-S) backupsuffix="$2"
shift;;

-t)
is_target_a_directory=always
dst_arg=$2
Expand Down Expand Up @@ -255,6 +275,10 @@ do
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else

# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
Expand Down Expand Up @@ -301,22 +325,6 @@ do
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;

*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac

# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
Expand All @@ -326,52 +334,49 @@ do
fi

posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$

trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0

# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$

trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0

# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac

if
Expand All @@ -382,7 +387,7 @@ do
then :
else

# The umask is ridiculous, or mkdir does not conform to POSIX,
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.

Expand Down Expand Up @@ -411,7 +416,7 @@ do
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
Expand Down Expand Up @@ -488,6 +493,13 @@ do
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi

# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||

Expand All @@ -502,9 +514,9 @@ do
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
Expand Down
4 changes: 2 additions & 2 deletions man/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign man/Makefile
$(AUTOMAKE) --gnu man/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
Expand Down
3 changes: 3 additions & 0 deletions man/slowhttptest.1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
.Op Fl r Ar connection per second
.Op Fl s Ar value of Content-Length header
.Op Fl t Ar HTTP verb
.Op Fl 1 Ar HTTP header
.Op Fl u Ar absolute URL
.Op Fl v Ar output verbosity level
.Op Fl w Ar advertised window size range start
Expand Down Expand Up @@ -120,6 +121,8 @@ Specifies the connection rate.
Specifies the value of Content-Length header for Slow POST test.
.It Fl t Ar HTTP verb
Specifies the verb to use in HTTP request.
.It Fl 1 Ar header
Specifies an HTTP header to use in HTTP request.
.It Fl u Ar URL
Specifies the URL.
.It Fl v Ar level
Expand Down
2 changes: 1 addition & 1 deletion missing
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

scriptversion=2018-03-07.03; # UTC

# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <[email protected]>, 1996.

# This program is free software; you can redistribute it and/or modify
Expand Down
16 changes: 15 additions & 1 deletion src/slowhttptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const char* SlowHTTPTest::get_random_extra() {

bool SlowHTTPTest::init(const char* url, const char* verb,
const char* path, const char* proxy,
const char* content_type, const char* accept, const char* cookie) {
const char* content_type, const char* accept, const char* cookie, const char* header) {
if(!change_fd_limits()) {
slowlog(LOG_INFO, "error setting open file limits\n");

Expand Down Expand Up @@ -340,6 +340,12 @@ bool SlowHTTPTest::init(const char* url, const char* verb,
request_.append(cookie_);
request_.append(crlf);
}
// Header
if (header != 0 && strlen(header)) {
header_.append(header);
request_.append(header_);
request_.append(crlf);
}
// method for probe is always GET
probe_request_.append("GET");
if(eProbeProxy == proxy_type_) {
Expand Down Expand Up @@ -400,6 +406,7 @@ bool SlowHTTPTest::init(const char* url, const char* verb,
"<tr><td><b>Verb</b></td><td>%s</td></tr>"
"<tr><td><b>Content-Length header value</b></td><td>%d</td></tr>"
"<tr><td><b>Cookie</b></td><td>%s</td></tr>"
"<tr><td><b>Header</b></td><td>%s</td></tr>"
"<tr><td><b>Extra data max length</b></td><td>%d</td></tr>"
"<tr><td><b>Interval between follow up data</b></td><td>%d seconds</td></tr>"
"<tr><td><b>Connections per seconds</b></td><td>%d</td></tr>"
Expand All @@ -412,6 +419,7 @@ bool SlowHTTPTest::init(const char* url, const char* verb,
verb_.c_str(),
content_length_,
cookie,
header,
extra_data_max_len_total_,
followup_timing_,
delay_,
Expand All @@ -426,6 +434,7 @@ bool SlowHTTPTest::init(const char* url, const char* verb,
"<tr><td><b>Test type</b></td><td>%s</td></tr>"
"<tr><td><b>Number of connections</b></td><td>%d</td></tr>"
"<tr><td><b>Cookie</b></td><td>%s</td></tr>"
"<tr><td><b>Header</b></td><td>%s</td></tr>"
"<tr><td><b>Receive window range</b></td><td>%d - %d</td></tr>"
"<tr><td><b>Pipeline factor</b></td><td>%d</td></tr>"
"<tr><td><b>Read rate from receive buffer</b></td><td>%d bytes / %d sec</td></tr>"
Expand All @@ -437,6 +446,7 @@ bool SlowHTTPTest::init(const char* url, const char* verb,
test_type_name[test_type_],
num_connections_,
cookie,
header,
window_lower_limit_,
window_upper_limit_,
pipeline_factor_,
Expand Down Expand Up @@ -497,6 +507,7 @@ void SlowHTTPTest::report_parameters() {
cBLU "URL:" cLBL " %s\n"
cBLU "verb:" cLBL " %s\n"
cBLU "cookie:" cLBL " %s\n"
cBLU "header:" cLBL " %s\n"
cBLU "Content-Length header value:" cLBL " %d\n"
cBLU "follow up data max size:" cLBL " %d\n"
cBLU "interval between follow up data:" cLBL " %d seconds\n"
Expand All @@ -509,6 +520,7 @@ void SlowHTTPTest::report_parameters() {
base_uri_.getData(),
verb_.c_str(),
cookie_.c_str(),
header_.c_str(),
content_length_,
extra_data_max_len_total_,
followup_timing_,
Expand All @@ -526,6 +538,7 @@ void SlowHTTPTest::report_parameters() {
cBLU "URL:" cLBL " %s\n"
cBLU "verb:" cLBL " %s\n"
cBLU "cookie:" cLBL" %s\n"
cBLU "header:" cLBL " %s\n"
cBLU "receive window range:" cLBL " %d - %d\n"
cBLU "pipeline factor:" cLBL " %d\n"
cBLU "read rate from receive buffer:" cLBL " %d bytes / %d sec\n"
Expand All @@ -538,6 +551,7 @@ void SlowHTTPTest::report_parameters() {
base_uri_.getData(),
verb_.c_str(),
cookie_.c_str(),
header_.c_str(),
window_lower_limit_,
window_upper_limit_,
pipeline_factor_,
Expand Down
3 changes: 2 additions & 1 deletion src/slowhttptest.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SlowHTTPTest {

bool init(const char* url, const char* verb,
const char* path, const char* proxy,
const char* content_type, const char* accept, const char* cookie);
const char* content_type, const char* accept, const char* cookie, const char* header);
void report_parameters();
void report_status(bool to_csv);
void report_csv();
Expand All @@ -100,6 +100,7 @@ class SlowHTTPTest {
std::string random_extra_;
std::string verb_;
std::string cookie_;
std::string header_;
std::string user_agent_;
std::string content_type_;
std::string accept_;
Expand Down
Loading

0 comments on commit 0eceeab

Please sign in to comment.