add init world data
This commit is contained in:
@@ -17,17 +17,55 @@ func (conf *Config) PostAuthenticationData() (*http.Response, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header := http.Header{}
|
||||
header.Set("Cookie", fmt.Sprintf("session=%s", conf.SessionID))
|
||||
header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||
header.Set("Connection", "keep-alive")
|
||||
header := conf.GetRequestHeader()
|
||||
header.Set("Content-Length", fmt.Sprintf("%d", len(authData.Encode())))
|
||||
header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
header.Set("Host", conf.Host)
|
||||
header.Set("Origin", fmt.Sprintf("http://%s", conf.Host))
|
||||
header.Set("Referer", fmt.Sprintf("http://%s%s", conf.Host, AuthPath))
|
||||
|
||||
req.Header = header
|
||||
req.Header = header.Clone()
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (conf *Config) PostLaunchWorld(world string) (*http.Response, error) {
|
||||
launchData := url.Values{}
|
||||
launchData.Add("world", world)
|
||||
launchData.Add("action", "launchWorld")
|
||||
|
||||
req, err := http.NewRequest("POST", fmt.Sprintf("http://%s%s", conf.Host, SetupPath), bytes.NewBuffer([]byte(launchData.Encode())))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header := conf.GetRequestHeader()
|
||||
header.Set("Content-Length", fmt.Sprintf("%d", len(launchData.Encode())))
|
||||
|
||||
req.Header = header.Clone()
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (conf *Config) PostReturnToSetup() (*http.Response, error) {
|
||||
launchData := url.Values{}
|
||||
launchData.Add("action", "shutdown")
|
||||
|
||||
req, err := http.NewRequest("POST", fmt.Sprintf("http://%s%s", conf.Host, JoinPath), bytes.NewBuffer([]byte(launchData.Encode())))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header := conf.GetRequestHeader()
|
||||
header.Set("Content-Length", fmt.Sprintf("%d", len(launchData.Encode())))
|
||||
|
||||
req.Header = header.Clone()
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
|
||||
Reference in New Issue
Block a user