---
# System prepended metadata

title: Untitled

---

### Test for 200 error code (no error) response 

* #### Test for file in root directory
* ![image alt](https://drive.google.com/file/d/1v1cOdecXQmc5J9QV3F_JIKs0xLhvmICj/view?usp=sharing)
    1. Search for .html file in root directory
    ```
    Test rootDirectoryile:
    GET /index.html HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>
    
    Expexted:
    HTTP/1.1 200 Ok
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>
    ```
    2. map "\\" to "\index.html"
    ```
    GET / HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>

    Expected:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>
    ```
    3. Get .jpg file
    ```
    Request:
    GET /kitten.jpg HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: image/jpeg
    Content-Length: 145459
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    ... (the content is in binary format)
    
    Expected:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: image/jpeg
    Content-Length: 145459
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    ... (the content is in binary format)
    ```
* #### Test for file in subdirectory
    1. Get default file in subdirectory
    ```
    Request:
    GET /subdir1/ HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 177
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
        <title>Basic subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    
    Expected:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 177
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
        <title>Basic subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    ```
    2. Get default file in sub-subdirectory
    ```
    Request:
    GET /subdir1/subdir11/ HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 184
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
        <title>Twice subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a double-subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    
    Expected:
    HTTP/1.1 200 Ok
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 184
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700

    <html>
    <head>
        <title>Twice subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a double-subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    ```
    
* #### Test for file of non-MIME type 
    ```
    Request:
    GET /subdir1/subdir11/maoyo.giaogiao HTTP/1.1
    Host:myHost
    
    Result:
    HTTP/1.1 200 Ok
    Content-Length: 4
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: application/octet-stream

    Yeet
    Expected:
    HTTP/1.1 200 Ok
    Content-Length: 4
    Last-Modified: Thu, 22 Oct 2020 11:42:08 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: application/octet-stream
    
    Yeet
    ```



### Test for handles 404 files that are't found

* #### Test for handles 404 files that aren't found
    1. Search for some unavailable file in the root directory
    ```
    Test FileNotFoundRequest1：
    GET /happy.html HTTP/1.1\r\n
    Host:myHost\r\n\r\n
    
    Result:
    HTTP/1.1 404 File Not Found\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 404 File Not Found\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
    2. Search for some unavailable file in child directory 
    ```
    Test FileNotFoundRequest2：
    GET /subdir1/hello.jpg HTTP/1.1\r\n
    Host:myHost\r\n\r\n

    Result:
    HTTP/1.1 404 File Not Found\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 404 File Not Found\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
* #### Test for handle URL that escape the doc root
    1. escape to one level above the doc root
    ```
    Test EscapeRootRequest1：
    GET /../README.md HTTP/1.1\r\n
    Host: myHost\r\n\r\n

    Result:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
    2. escape to two level above the doc root
     ```
    Test EscapeRootRequest2：
    GET /../../module-1-project-224-link/readme.txt HTTP/1.1\r\n
    Host: myHost\r\n\r\n

    Result:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
* #### Test for MalFormed Request
    1. get is not capitalized
     ```
    Test MalFormRequest1：
    get /index.html HTTP/1.1\r\n
    Host: myHost\r\n\r\n

    Result:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
    2. missing column for headers
     ```
    Test MalFormRequest2：
    get /index.html HTTP/1.1\r\n
    Host myHost\r\n\r\n

    Result:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
    3. missing http version in request
     ```
    Test MalFormRequest3：
    get /index.html\r\n
    Host: myHost\r\n\r\n

    Result:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    
    Expected:
    HTTP/1.1 400 Bad Request\r\n
    Server: Go-Triton-Server-1.0\r\n\r\n
    ```
### Test for Concurrency
```
Running shell script at testing/concurrentTest/test.sh:
```
1. Test 1 running two same requests with different connection
```
Test:
cat ConcurrentRequest1.text| nc localhost 8080 & cat ConcurrentRequest1.text| nc localhost 8080

--------------------------Result-------------------------:
HTTP/1.1 200 Ok
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
HTTP/1.1 200 Ok
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
-------------------------Expected-----------------------:
HTTP/1.1 200 Ok
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
HTTP/1.1 200 Ok
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
```
2. Test 2 running two different requests with different connection
```
Test:
cat ConcurrentRequest1.text| nc localhost 8080 & cat ConcurrentRequest2.text| nc localhost 8080

--------------------------Result-------------------------:
HTTP/1.1 200 Ok
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0
Content-Type: text/html

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
HTTP/1.1 200 Ok
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>

-------------------------Expected-----------------------:
HTTP/1.1 200 Ok
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0
Content-Type: text/html

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
HTTP/1.1 200 Ok
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
```
3. Test with 2 continuous connections
Using test.go which sends request to the server every 4.5 seconds
```
Test:
go run ../test.go & go run ../test.go

Result:
Every 4.5 seconds receive two response

Expected：
Every 4.5 seconds receive two response

Code:
package main

import (
	"bufio"
	"fmt"
	"net"
	"time"
)

func validRequest() {
	conn, err := net.Dial("tcp", "localhost:8080")
	defer conn.Close()
	if err != nil {
		// handle error
		fmt.Errorf("Unable to connect to server")
	}

	timer := time.NewTicker(4*time.Second + 500*time.Millisecond)

	go func() {
		fmt.Printf("Listen start")
		for {
			p := make([]byte, 1024)
			_, err := bufio.NewReader(conn).Read(p)
			// ...
			if err == nil {
				fmt.Printf("%s", p)
			} else {
				fmt.Printf("Some error %v\n", err)
				break
			}
		}
	}()

	for {

		select {

		case <-timer.C:
			fmt.Print("Request sent")
			fmt.Fprint(conn, "GET /index.html HTTP/1.1\r\nHost:myHost\r\n\r\n")
		}

	}
}

func main() {
	validRequest()
}
```
### Test for Pipeline
* #### Handle pipeLine requests
    1.  Handle two requests in the same connection
    ```
    test PipeLineRequest1:
    GET /subdir1/index.html HTTP/1.1\r\n
    Host:myHost\r\n\r\n
    GET /index.html HTTP/1.1\r\n
    Host:myHost\r\n\r\n
    --------------------------Result-------------------------:
    HTTP/1.1 200 OK
    Content-Length: 177
    Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: text/html

    <html>
    <head>
        <title>Basic subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    HTTP/1.1 200 OK
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307
    Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>
  
  -------------------------Expected-----------------------:
    HTTP/1.1 200 OK
    Content-Length: 177
    Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
    Server: Go-Triton-Server-1.0
    Content-Type: text/html

    <html>
    <head>
        <title>Basic subdirectory file</title>
    </head>
    <body>
    <h1>This is a basic index file for a subdirectory</h1>
    You can use this for testing.
    <p>
    </body>
    </html>
    HTTP/1.1 200 OK
    Server: Go-Triton-Server-1.0
    Content-Type: text/html
    Content-Length: 307
    Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

    <html>
    <head>
    <title>Basic index file</title>
    </head>
    <body>
    <h1>This is a basic index file</h1>
    You can use this for testing.
    <p>
    <ul>
    <li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
    <li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
    <li><a href=subdir1/>A subdirectory</a>
    </ul>
    </body>
    </html>
    ```
    2. Handle three requests
```
test PipelineTest2:
GET /subdir1/index.html HTTP/1.1\r\n
Host:myHost\r\n\r\n
GET /index.html HTTP/1.1\r\n
Host:myHost\r\n\r\n
GET /index.html HTTP/1.1\r\n
Host:myHost\r\n\r\n
 --------------------------Result-------------------------:
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
-------------------------Expected-----------------------:
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 177
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
    <title>Basic subdirectory file</title>
</head>
<body>
<h1>This is a basic index file for a subdirectory</h1>
You can use this for testing.
<p>
</body>
</html>
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Server: Go-Triton-Server-1.0

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
```
* #### Handle Connection: Close Header correctly
```
test PipelineTest3:
GET /subdir1/index.html HTTP/1.1\r\n
Host:myHost\r\n
Conncetion: close\r\n\r\n
--------------------------Result-------------------------:
HTTP/1.1 200 OK
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Connection: close
Server: Go-Triton-Server-1.0
Content-Type: text/html

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
-------------------------Expected-----------------------:
HTTP/1.1 200 OK
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700
Connection: close
Server: Go-Triton-Server-1.0
Content-Type: text/html

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
```
* #### 5 Seconds timeout: 
1. auto close (Normal good connection would close after 5 seconds) Checking using time 
`( cat PipelineRequest4.text | nc localhost 8080; )  0.00s user 0.00s system 0% cpu 5.004 total` which is 5s.
```
test PipelineRequest4:
GET /index.html HTTP/1.1\r\n
Host:myHost\r\n\r\n
--------------------------Result-------------------------:
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
-------------------------Expected-----------------------:
HTTP/1.1 200 OK
Server: Go-Triton-Server-1.0
Content-Type: text/html
Content-Length: 307
Last-Modified: Wed, 21 Oct 2020 17:01:38 -0700

<html>
<head>
<title>Basic index file</title>
</head>
<body>
<h1>This is a basic index file</h1>
You can use this for testing.
<p>
<ul>
<li><a href=UCSD_Seal.png alt="UCSD Seal">UCSD seal</a>
<li><a href=kitten.jpg alt="Kitten">Kitten photo</a>
<li><a href=subdir1/>A subdirectory</a>
</ul>
</body>
</html>
```
2. timeout refresh after a successful read
Using test.go which sends a request every 4.5 seconds. Connection continues forever(which means the time out is refreshed)
```
package main

import (
	"bufio"
	"fmt"
	"net"
	"time"
)

func validRequest() {
	conn, err := net.Dial("tcp", "localhost:8080")
	defer conn.Close()
	if err != nil {
		// handle error
		fmt.Errorf("Unable to connect to server")
	}

	timer := time.NewTicker(4*time.Second + 500*time.Millisecond)

	go func() {
		fmt.Printf("Listen start")
		for {
			p := make([]byte, 1024)
			_, err := bufio.NewReader(conn).Read(p)
			// ...
			if err == nil {
				fmt.Printf("%s", p)
			} else {
				fmt.Printf("Some error %v\n", err)
				break
			}
		}
	}()

	for {

		select {

		case <-timer.C:
			fmt.Print("Request sent")
			fmt.Fprint(conn, "GET /index.html HTTP/1.1\r\nHost:myHost\r\n\r\n")
		}

	}
}

func main() {
	validRequest()
}

```