Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Client/.DS_Store
Binary file not shown.
25 changes: 25 additions & 0 deletions Client/Client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"log"
"net/http"
"net/http/httputil"
)

func main() {
url := "http://10.50.0.129:9999/hi"
req, _ := http.NewRequest("GET", url, nil)
res, err := http.Head(url)
res.Header.Set("Hello", "BasicHTTP!")
if err != nil {
log.Fatal(err)
}

dumpRes, _ := httputil.DumpResponse(res, true)
fmt.Printf("%s", dumpRes)

dump, _ := httputil.DumpRequestOut(req, true)
fmt.Printf("%s", dump)

}
9 changes: 9 additions & 0 deletions Curl.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Please show HTTP Request and Response using curl command


toukaininnoMacBook-Pro% curl -i http://10.50.0.129:9999/hi
HTTP/1.1 200 OK
Date: Wed, 10 Jun 2020 18:40:05 GMT
Content-Length: 12
Content-Type: text/plain; charset=utf-8

10.50.0.129
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Exp3BasicHttp
For Labo of Basic HTTP for Exp3 of Univ

## Mission

1. show Server Directory README.md
2. show Client Directory README.md
2. show Curl.md

## Setup

1. access 'https://github.com/Hardw01f/Exp3BasicHttp'
Expand Down
Binary file added Server/.DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions Server/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Please write code of simple HTTP(Web) server

write this directory

## Specification

- write by using favorit language

- listen the API '/hi'
- return your IP address in Response Body
- return 'Hello: BasicHTTP!' Header in Response Header

## Response Exsample

```
HTTP/1.1 200 OK
Hello: BasicHTTP!
Date: Tue, 26 May 2020 06:53:14 GMT
Content-Length: 13
Content-Type: text/plain; charset=utf-8

10.10.11.194

```
24 changes: 24 additions & 0 deletions Server/Server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"fmt"
"net"
"net/http"
)

func getipv4 (w http.ResponseWriter, r *http.Request){
addrs, _ := net.InterfaceAddrs()
for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback(){
if ipnet.IP.To4() != nil {
fmt.Fprintln(w, ipnet.IP.String())
break
}
}
}
}

func main() {
http.HandleFunc("/hi", getipv4)
http.ListenAndServe(":9999",nil)
}