-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttpPost_readFile.go
71 lines (63 loc) · 1.14 KB
/
httpPost_readFile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
)
func UnZipData(Body io.ReadCloser) {
/*
body, err := ioutil.ReadAll(Body)
checkErr(err)
fmt.Printf("%v", body)
// r, err := gzip.NewReader(&body)
/**/
r, err := gzip.NewReader(Body)
//
defer r.Close()
checkErr(err)
unDatas, _ := ioutil.ReadAll(r)
ParseJson(unDatas)
}
func json_unMarshal(r *bufio.Reader) {
//data, err := ioutil.ReadAll(r)
//checkErr(err)
//err = json.NewDecoder(r).Decode(value)
}
func CovertToResponse(r *bufio.Reader) {
resp, err := http.ReadResponse(r, nil)
checkErr(err)
fmt.Printf("\r\nConver:-->%v\r\n", resp)
UnZipData(resp.Body)
}
func httpPost_readFile_main() {
fread, err := os.Open("r.txt")
defer fread.Close()
checkErr(err)
/*
buf := make([]byte, 1024)
for {
n, _ := fread.Read(buf)
if 0 == n {
break
}
//os.Stdout.Write(buf[:n])
break
}
/**/
br := bufio.NewReader(fread)
/*nCount := 0
for {
line, err := br.ReadString(`\n`)
if err == io.EOF {
break
}
fmt.Printf("%d-->%v", nCount, line)
nCount += 1
}/**/
//tp := textproto.NewReader(br)
CovertToResponse(br)
}