func UpdateWebappTaskV2(vars task_common.UpdateTaskVars) error { postUrl := WebappRoot + vars.UriPath() glog.Infof("Updating %v on %s", vars, postUrl) json, err := json.Marshal(vars) if err != nil { return fmt.Errorf("Failed to marshal %v: %s", vars, err) } req, err := http.NewRequest("POST", postUrl, bytes.NewReader(json)) if err != nil { return fmt.Errorf("Could not create HTTP request: %s", err) } hash, err := webhook.ComputeAuthHashBase64(json) if err != nil { return fmt.Errorf("Could not compute authentication hash: %s", err) } req.Header.Set(webhook.REQUEST_AUTH_HASH_HEADER, hash) client := util.NewTimeoutClient() resp, err := client.Do(req) if err != nil { return fmt.Errorf("Could not update webapp task: %s", err) } defer util.Close(resp.Body) if resp.StatusCode != 200 { response, _ := ioutil.ReadAll(resp.Body) return fmt.Errorf("Could not update webapp task, response status code was %d: %s", resp.StatusCode, response) } return nil }
func UpdateWebappTaskSetStarted(vars task_common.UpdateTaskVars, id int64) error { vars.GetUpdateTaskCommonVars().Id = id vars.GetUpdateTaskCommonVars().SetStarted() return UpdateWebappTaskV2(vars) }