Skip to content

Commit

Permalink
add wr840n specific utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
furtidev committed Nov 11, 2023
1 parent 1fef2cc commit b41ad39
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions wr840n/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package wr840n

import (
"net/http"
"io"
"strings"
)

func MakeRequest(url string, payload string, auth string) (string, error) {
req, err := http.NewRequest("POST", url, strings.NewReader(payload))
if err != nil {
return "", err
}
req.Header.Add("Referer", "http://192.168.0.1/mainFrame.htm")
req.Header.Add("Content-Type", "text/plain")
req.Header.Add("charset", "UTF-8")
req.Header.Add("Cookie", "Authorization="+auth)

res, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}

defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil {
return "", err
}
return string(body), nil
}

0 comments on commit b41ad39

Please sign in to comment.