-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add wr840n specific utility functions
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |