From 13e2efc62391239e9890e63b61c0501cf92f12f1 Mon Sep 17 00:00:00 2001 From: Hardw01f Date: Tue, 26 May 2020 15:55:51 +0900 Subject: [PATCH 1/4] Update README.md --- Server/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Server/README.md b/Server/README.md index 27b8f2a..572e856 100644 --- a/Server/README.md +++ b/Server/README.md @@ -1,5 +1,7 @@ # Please write code of simple HTTP(Web) server +write this directory + ## Specification - write by using favorit language @@ -7,3 +9,16 @@ - 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 + +``` From 31e27aa92f6a367779d776e4142fe50b9aae70f3 Mon Sep 17 00:00:00 2001 From: Hardw01f Date: Thu, 28 May 2020 00:28:54 +0900 Subject: [PATCH 2/4] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 99b6488..f9f87ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Exp3BasicHttp For Labo of Basic HTTP for Exp3 of Univ +Please show Server & Client Directory README.md + ## Setup 1. access 'https://github.com/Hardw01f/Exp3BasicHttp' From 54a664f2ba2198ae7e953450a410ac8d96ad55fa Mon Sep 17 00:00:00 2001 From: Hardw01f Date: Thu, 28 May 2020 00:31:10 +0900 Subject: [PATCH 3/4] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f9f87ac..1f3606e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # Exp3BasicHttp For Labo of Basic HTTP for Exp3 of Univ -Please show Server & Client Directory README.md +## Mission + +1. show Server Directory README.md +2. show Client Directory README.md +2. show Curl.md ## Setup From de8d9a89db19b7ae9366893f7e551834f985f230 Mon Sep 17 00:00:00 2001 From: Kaito Higashi Date: Thu, 11 Jun 2020 15:45:52 +0900 Subject: [PATCH 4/4] first commit --- .DS_Store | Bin 0 -> 6148 bytes Client/.DS_Store | Bin 0 -> 6148 bytes Client/Client.go | 25 +++++++++++++++++++++++++ Curl.md | 9 +++++++++ Server/.DS_Store | Bin 0 -> 6148 bytes Server/Server.go | 24 ++++++++++++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 .DS_Store create mode 100644 Client/.DS_Store create mode 100644 Client/Client.go create mode 100644 Server/.DS_Store create mode 100644 Server/Server.go diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..318e6717b02344c5f8542848df9bf3d94e72bda3 GIT binary patch literal 6148 zcmeHK&2G~`5T0#K;shabKx&V^AaSUwl%G~rg=Es?5D5^%2o8W+8(Xa<*IOk{Bbo;J z!aD$Oz@zX4JO~c}-|Q|ZP6`qigxVcx=bPP~8E3wYcfCX;I-_`ls6|9B8l%&MI!Ab( z+kz~a5snj_qo2t)Q6?kwIiVHHfMwwSW`N&aht}zUQYz-&-yO`|`mRJ3QKMbT;FnOo z;QRSczR`GiZ1#mO(Q%dzi+1~~SXy?j)atI=beq?juY*H54vMfC4LjlBCHJ0$#bIRZ zXHsUr>@a$sCgZ)uG?@Md#%;U$_*pys1_!Bs=I>;K)0EDg65ye$%#R@z=%urjWhtx+zj~-J%y*cmq@Sa_W20ex61M1Qv;CcDK z%|+CZHNmerVO`Bmyv(z|rQ&;Wmu`lTxupXimqN^6+r4@zs zu+*rw4k&d606G{}0$Y9h13ex9`UXpl7=Z{K3e=&(Trq^XIS3t&dEfY#8g)1c^oGuhDADfMuY{z_RYP`26qv{{CMLvOUXyW#B?FAe?T{?Vu!cwk{OM vXRU{}kH*4&rA8G3WsYNI@KL;qrUY{y8$jP+sSzU(`yrrcu*x#r-SMyd1k65yVi{Trv@7k- z-QJGRp2B+vK$dUY3t$FdN>{|YhOz0o`pAwVqbT-_SL`sy6S{Rfs{T2l+!I`*#WNmp z!0#S5ZMWg7zS;-<>NCt3w^(6;1~#So`6 zU!txC_Kr@6*v@=T>@0CZ5!;>lV&#zPm@ySd1%?V7`*f!Le?|Z0{y!w;EEPxv{*?kU zY3`aOKPh_a=;O547WzGXZ>+U)hQT3#6K%z32X#fqtgC^&qtTf+Ix!Cds!Lib@D~bv E0b{2rcmMzZ literal 0 HcmV?d00001 diff --git a/Client/Client.go b/Client/Client.go new file mode 100644 index 0000000..a37dbbc --- /dev/null +++ b/Client/Client.go @@ -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) + +} \ No newline at end of file diff --git a/Curl.md b/Curl.md index ce6f29d..addb29a 100644 --- a/Curl.md +++ b/Curl.md @@ -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 \ No newline at end of file diff --git a/Server/.DS_Store b/Server/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..75797565d424dbd4b834aac674ad55103bce4bc9 GIT binary patch literal 6148 zcmeHKyH3ME5S)b+K{P2TucV4ZO>;y}k%ET&0181gjw~TT?T+u{OUh-GLg(5|#Q zcY8ZNdkXIz09n24uYd)BIb9KN8m6Y}>JvMOjH1{xZn4G^2kbZPr26NCa?fx_-VGWY z@wFjnByrwi@>Yx*zu|1l|NsX!|5uN073 zvu#%Vr0A`akJDaT==bzbW381lj1B>uXe+)rsw+BXT@CCVjn2H$iFpuEUD8s4zfj-< DBugn9 literal 0 HcmV?d00001 diff --git a/Server/Server.go b/Server/Server.go new file mode 100644 index 0000000..127106e --- /dev/null +++ b/Server/Server.go @@ -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) +} \ No newline at end of file