Skip to content

Commit

Permalink
fixing Content-type init with payload. (fortio#405)
Browse files Browse the repository at this point in the history
* fixing Content-type init with payload. Fixes fortio#404

* bumping version to 1.8.1
  • Loading branch information
ldemailly authored Oct 1, 2020
1 parent 256b310 commit 4f6bbfb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ docker run fortio/fortio load http://www.google.com/ # For a test run
Or download one of the binary distributions, from the [releases](https://github.com/fortio/fortio/releases) assets page or for instance:

```shell
curl -L https://github.com/fortio/fortio/releases/download/v1.8.0/fortio-linux_x64-1.8.0.tgz \
curl -L https://github.com/fortio/fortio/releases/download/v1.8.1/fortio-linux_x64-1.8.1.tgz \
| sudo tar -C / -xvzpf -
# or the debian package
wget https://github.com/fortio/fortio/releases/download/v1.8.0/fortio_1.8.0-1_amd64.deb
dpkg -i fortio_1.8.0-1_amd64.deb
wget https://github.com/fortio/fortio/releases/download/v1.8.1/fortio_1.8.1-1_amd64.deb
dpkg -i fortio_1.8.1-1_amd64.deb
# or the rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.8.0/fortio-1.8.0-1.x86_64.rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.8.1/fortio-1.8.1-1.x86_64.rpm
```

On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
Expand All @@ -59,7 +59,7 @@ On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
brew install fortio
```

On Windows, download https://github.com/fortio/fortio/releases/download/v1.8.0/fortio_win_1.8.0.zip and extract all to some location then using the Windows Command Prompt:
On Windows, download https://github.com/fortio/fortio/releases/download/v1.8.1/fortio_win_1.8.1.zip and extract all to some location then using the Windows Command Prompt:
```
cd fortio
fortio.exe server
Expand Down Expand Up @@ -103,7 +103,7 @@ Full list of command line flags (`fortio help`):
<details>
<!-- use release/updateFlags.sh to update this section -->
<pre>
Φορτίο 1.8.0 usage:
Φορτίο 1.8.1 usage:
fortio command [flags] target
where command is one of: load (load testing), server (starts ui, http-echo,
redirect, proxies, tcp-echo and grpc ping servers), tcp-echo (only the tcp-echo
Expand Down Expand Up @@ -274,15 +274,15 @@ See also the FAQ entry about [fortio flags for best results](https://github.com/
```Shell
$ fortio server &
14:11:05 I fortio_main.go:171> Not using dynamic flag watching (use -config to set watch directory)
Fortio 1.8.0 tcp-echo server listening on [::]:8078
Fortio 1.8.0 grpc 'ping' server listening on [::]:8079
Fortio 1.8.0 https redirector server listening on [::]:8081
Fortio 1.8.0 echo server listening on [::]:8080
Fortio 1.8.1 tcp-echo server listening on [::]:8078
Fortio 1.8.1 grpc 'ping' server listening on [::]:8079
Fortio 1.8.1 https redirector server listening on [::]:8081
Fortio 1.8.1 echo server listening on [::]:8080
Data directory is /Users/ldemailly/go/src/fortio.org/fortio
UI started - visit:
http://localhost:8080/fortio/
(or any host/ip reachable on this server)
14:11:05 I fortio_main.go:233> All fortio 1.8.0 release go1.15.2 servers started!
14:11:05 I fortio_main.go:233> All fortio 1.8.1 release go1.15.2 servers started!
```

### Change the port / binding address
Expand All @@ -295,8 +295,8 @@ $ fortio server -http-port 10.10.10.10:8088
UI starting - visit:
http://10.10.10.10:8088/fortio/
Https redirector running on :8081
Fortio 1.8.0 grpc ping server listening on port :8079
Fortio 1.8.0 echo server listening on port 10.10.10.10:8088
Fortio 1.8.1 grpc ping server listening on port :8079
Fortio 1.8.1 echo server listening on port 10.10.10.10:8088
```

### Unix domain sockets
Expand All @@ -305,27 +305,27 @@ You can use unix domain socket for any server/client:

```Shell
$ fortio server --http-port /tmp/fortio-uds-http &
Fortio 1.8.0 grpc 'ping' server listening on [::]:8079
Fortio 1.8.0 https redirector server listening on [::]:8081
Fortio 1.8.0 echo server listening on /tmp/fortio-uds-http
Fortio 1.8.1 grpc 'ping' server listening on [::]:8079
Fortio 1.8.1 https redirector server listening on [::]:8081
Fortio 1.8.1 echo server listening on /tmp/fortio-uds-http
UI started - visit:
fortio curl -unix-socket=/tmp/fortio-uds-http http://localhost/fortio/
14:58:45 I fortio_main.go:217> All fortio 1.8.0 unknown go1.10.3 servers started!
14:58:45 I fortio_main.go:217> All fortio 1.8.1 unknown go1.10.3 servers started!
$ fortio curl -unix-socket=/tmp/fortio-uds-http http://foo.bar/debug
15:00:48 I http_client.go:428> Using unix domain socket /tmp/fortio-uds-http instead of foo.bar http
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Date: Wed, 08 Aug 2018 22:00:48 GMT
Content-Length: 231

Φορτίο version 1.8.0 unknown go1.10.3 echo debug server up for 2m3.4s on ldemailly-macbookpro - request from
Φορτίο version 1.8.1 unknown go1.10.3 echo debug server up for 2m3.4s on ldemailly-macbookpro - request from

GET /debug HTTP/1.1

headers:

Host: foo.bar
User-Agent: fortio.org/fortio-1.8.0
User-Agent: fortio.org/fortio-1.8.1

body:
```
Expand All @@ -334,10 +334,10 @@ body:
Start the echo-server alone and run a load (use `tcp://` prefix for the load test to be for tcp echo server)
```Shell
$ fortio echo-server &
Fortio 1.8.0 tcp-echo server listening on [::]:8078
19:45:30 I fortio_main.go:238> All fortio 1.8.0 release go1.15.2 servers started!
Fortio 1.8.1 tcp-echo server listening on [::]:8078
19:45:30 I fortio_main.go:238> All fortio 1.8.1 release go1.15.2 servers started!
$ load -qps -1 -n 100000 tcp://localhost:8078
Fortio 1.8.0 running at -1 queries per second, 16->16 procs, for 100000 calls: tcp://localhost:8078
Fortio 1.8.1 running at -1 queries per second, 16->16 procs, for 100000 calls: tcp://localhost:8078
20:01:31 I tcprunner.go:218> Starting tcp test for tcp://localhost:8078 with 4 threads at -1.0 qps
Starting at max qps with 4 thread(s) [gomax 16] for exactly 100000 calls (25000 per thread + 0)
20:01:32 I periodic.go:558> T003 ended after 1.240585427s : 25000 calls. qps=20151.77629520873
Expand Down Expand Up @@ -408,8 +408,8 @@ $ fortio server -cert /path/to/fortio/server.crt -key /path/to/fortio/server.key
UI starting - visit:
http://localhost:8080/fortio/
Https redirector running on :8081
Fortio 1.8.0 grpc ping server listening on port :8079
Fortio 1.8.0 echo server listening on port localhost:8080
Fortio 1.8.1 grpc ping server listening on port :8079
Fortio 1.8.1 echo server listening on port localhost:8080
Using server certificate /path/to/fortio/server.crt to construct TLS credentials
Using server key /path/to/fortio/server.key to construct TLS credentials
```
Expand Down Expand Up @@ -454,7 +454,7 @@ Load (low default qps/threading) test:

```Shell
$ fortio load http://www.google.com
Fortio 1.8.0 running at 8 queries per second, 8->8 procs, for 5s: http://www.google.com
Fortio 1.8.1 running at 8 queries per second, 8->8 procs, for 5s: http://www.google.com
19:10:33 I httprunner.go:84> Starting http test for http://www.google.com with 4 threads at 8.0 qps
Starting at 8 qps with 4 thread(s) [gomax 8] for 5s : 10 calls each (total 40)
19:10:39 I periodic.go:314> T002 ended after 5.056753279s : 10 calls. qps=1.9775534712220633
Expand Down Expand Up @@ -485,7 +485,7 @@ Uses `-s` to use multiple (h2/grpc) streams per connection (`-c`), request to hi

```bash
$ fortio load -a -grpc -ping -grpc-ping-delay 0.25s -payload "01234567890" -c 2 -s 4 https://fortio-stage.istio.io
Fortio 1.8.0 running at 8 queries per second, 8->8 procs, for 5s: https://fortio-stage.istio.io
Fortio 1.8.1 running at 8 queries per second, 8->8 procs, for 5s: https://fortio-stage.istio.io
16:32:56 I grpcrunner.go:139> Starting GRPC Ping Delay=250ms PayloadLength=11 test for https://fortio-stage.istio.io with 4*2 threads at 8.0 qps
16:32:56 I grpcrunner.go:261> stripping https scheme. grpc destination: fortio-stage.istio.io. grpc port: 443
16:32:57 I grpcrunner.go:261> stripping https scheme. grpc destination: fortio-stage.istio.io. grpc port: 443
Expand Down Expand Up @@ -590,14 +590,14 @@ Content-Type: text/plain; charset=UTF-8
Date: Mon, 08 Jan 2018 22:26:26 GMT
Content-Length: 230

Φορτίο version 1.8.0 echo debug server up for 39s on ldemailly-macbookpro - request from [::1]:65055
Φορτίο version 1.8.1 echo debug server up for 39s on ldemailly-macbookpro - request from [::1]:65055

GET /debug HTTP/1.1

headers:

Host: localhost:8080
User-Agent: fortio.org/fortio-1.8.0
User-Agent: fortio.org/fortio-1.8.1
Foo: Bar

body:
Expand All @@ -621,15 +621,15 @@ Example: open 2 additional listening ports and forward all requests received on

```Shell
$ fortio server -P "8888 [::1]:8080" -P "[::1]:8889 [::1]:8080"
Fortio 1.8.0 grpc 'ping' server listening on [::]:8079
Fortio 1.8.0 https redirector server listening on [::]:8081
Fortio 1.8.0 echo server listening on [::]:8080
Fortio 1.8.1 grpc 'ping' server listening on [::]:8079
Fortio 1.8.1 https redirector server listening on [::]:8081
Fortio 1.8.1 echo server listening on [::]:8080
Data directory is /home/dl
UI started - visit:
http://localhost:8080/fortio/
(or any host/ip reachable on this server)
Fortio 1.8.0 proxy for [::1]:8080 server listening on [::]:8888
Fortio 1.8.0 proxy for [::1]:8080 server listening on [::1]:8889
Fortio 1.8.1 proxy for [::1]:8080 server listening on [::]:8888
Fortio 1.8.1 proxy for [::1]:8080 server listening on [::1]:8889
```

## Server URLs and features
Expand Down
10 changes: 3 additions & 7 deletions ui/uihandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ func Handler(w http.ResponseWriter, r *http.Request) {
log.Infof("New run id %d", runid)
}
httpopts := fhttp.NewHTTPOptions(url)
defaultHeaders := httpopts.AllHeaders()
httpopts.ResetHeaders()
httpopts.DisableFastClient = stdClient
httpopts.Insecure = httpsInsecure
httpopts.Resolve = resolve
Expand Down Expand Up @@ -253,7 +255,7 @@ func Handler(w http.ResponseWriter, r *http.Request) {
DoStop bool
DoLoad bool
}{
r, httpopts.AllHeaders(), version.Short(), logoPath, debugPath, chartJSPath,
r, defaultHeaders, version.Short(), logoPath, debugPath, chartJSPath,
startTime.Format(time.ANSIC), url, labels, runid,
fhttp.RoundDuration(time.Since(startTime)), durSeconds, urlHostPort, mode == stop, mode == run,
})
Expand Down Expand Up @@ -284,17 +286,11 @@ func Handler(w http.ResponseWriter, r *http.Request) {
}
case run:
// mode == run case:
firstHeader := true
for _, header := range r.Form["H"] {
if len(header) == 0 {
continue
}
log.LogVf("adding header %v", header)
if firstHeader {
// If there is at least 1 non empty H passed, reset the header list
httpopts.ResetHeaders()
firstHeader = false
}
err := httpopts.AddAndValidateExtraHeader(header)
if err != nil {
log.Errf("Error adding custom headers: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
major = 1
minor = 8
patch = 0
patch = 1

debug = false // turn on to debug init()
)
Expand Down

0 comments on commit 4f6bbfb

Please sign in to comment.