Skip to content

Commit c7eb669

Browse files
committed
Merge branch 'release/v0.5.0-alpha'
2 parents 3494175 + e1201df commit c7eb669

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [v0.5.0-alpha] - 2020-11-16
8+
9+
### Changed
10+
- Ignore invalid SSL certificates
11+
12+
### Added
13+
- Log response headers
14+
715
## [v0.4.1-alpha] - 2020-11-16
816

917
### Fixed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ You can download binaries for Linux, macOS and Windows from [github.com »andrea
6464
Linux:
6565

6666
```bash
67-
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.4.1-alpha/gargantua_linux_amd64 -o gargantua
67+
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.5.0-alpha/gargantua_linux_amd64 -o gargantua
6868
chmod +x gargantua
6969
```
7070

7171
macOS:
7272

7373
```bash
74-
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.4.1-alpha/gargantua_darwin_amd64 -o gargantua
74+
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.5.0-alpha/gargantua_darwin_amd64 -o gargantua
7575
chmod +x gargantua
7676
```
7777

7878
Windows:
7979

8080
```bash
81-
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.4.1-alpha/gargantua_windows_amd64 -o gargantua.exe
81+
curl -L https://github.com/andreaskoch/gargantua/releases/download/v0.5.0-alpha/gargantua_windows_amd64 -o gargantua.exe
8282
```
8383

8484
## Docker Image

http.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"bytes"
5+
"crypto/tls"
56
"fmt"
67
"io"
78
"io/ioutil"
@@ -14,13 +15,18 @@ import (
1415
)
1516

1617
type Response struct {
18+
header map[string][]string
1719
body []byte
1820
statusCode int
1921
startTime time.Time
2022
endTime time.Time
2123
contentType string
2224
}
2325

26+
func (response *Response) Header() map[string][]string {
27+
return response.header
28+
}
29+
2430
func (response *Response) Body() []byte {
2531
return response.body
2632
}
@@ -59,7 +65,10 @@ func readURL(url url.URL, userAgent string) (Response, error) {
5965

6066
req.Header.Set("User-Agent", userAgent)
6167

62-
client := &http.Client{}
68+
tr := &http.Transport{
69+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
70+
}
71+
client := &http.Client{Transport: tr}
6372
resp, fetchErr := client.Do(req)
6473
if fetchErr != nil {
6574
return Response{}, fetchErr
@@ -80,7 +89,9 @@ func readURL(url url.URL, userAgent string) (Response, error) {
8089
}
8190

8291
return Response{
83-
body: body,
92+
body: body,
93+
header: resp.Header,
94+
8495
statusCode: resp.StatusCode,
8596
startTime: startTime,
8697
endTime: endTime,

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const applicationName = "gargantua"
14-
const applicationVersion = "v0.4.1-alpha"
14+
const applicationVersion = "v0.5.0-alpha"
1515

1616
var defaultUserAgent = fmt.Sprintf("%s bot (https://github.com/andreaskoch/gargantua)", applicationName)
1717

worker.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ func executeWork(workerID, numberOfWorkers int, targetURL crawlerUrl, userAgent
3636

3737
workResult := WorkResult{
3838
parentURL: targetURL.parent,
39-
url: targetURL.url,
39+
url: targetURL.url,
4040

4141
workerID: workerID,
4242
numberOfWorkers: numberOfWorkers,
4343

4444
responseSize: response.Size(),
45-
statusCode: response.StatusCode(),
46-
startTime: response.StartTime(),
47-
endTime: response.EndTime(),
48-
contentType: response.ContentType(),
45+
body: response.Body(),
46+
header: response.Header(),
47+
48+
statusCode: response.StatusCode(),
49+
startTime: response.StartTime(),
50+
endTime: response.EndTime(),
51+
contentType: response.ContentType(),
4952
}
5053

5154
return workResult

workresult.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"net/url"
6+
"strings"
67
"time"
78
)
89

@@ -16,20 +17,30 @@ type WorkResult struct {
1617
workerID int
1718

1819
responseSize int
19-
statusCode int
20-
startTime time.Time
21-
endTime time.Time
22-
contentType string
20+
body []byte
21+
header map[string][]string
22+
23+
statusCode int
24+
startTime time.Time
25+
endTime time.Time
26+
contentType string
2327
}
2428

2529
func (workResult WorkResult) String() string {
26-
return fmt.Sprintf("#%03d: %03d %9s %15s %20s %20s",
30+
31+
headers := []string{}
32+
for name, value := range workResult.header {
33+
headers = append(headers, fmt.Sprintf("'%s:%s'", name, value))
34+
}
35+
36+
return fmt.Sprintf("#%03d: %03d %9s %15s %20s %20s %s",
2737
workResult.workerID,
2838
workResult.statusCode,
2939
fmt.Sprintf("%d", workResult.responseSize),
3040
fmt.Sprintf("%fms", workResult.ResponseTime().Seconds()*1000),
3141
workResult.url.String(),
3242
workResult.parentURL.String(),
43+
strings.Join(headers, "|"),
3344
)
3445
}
3546

@@ -76,3 +87,11 @@ func (workResult WorkResult) WorkerID() int {
7687
func (workResult WorkResult) NumberOfWorkers() int {
7788
return workResult.numberOfWorkers
7889
}
90+
91+
func (workResult WorkResult) Body() []byte {
92+
return workResult.body
93+
}
94+
95+
func (workResult WorkResult) Header() map[string][]string {
96+
return workResult.header
97+
}

0 commit comments

Comments
 (0)