func (c *ArchiveInsertCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil c.urlParams_.Set("alt", alt) urls := googleapi.ResolveRelative(c.s.BasePath, "{groupId}/archive") if c.media_ != nil || c.resumable_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) c.urlParams_.Set("uploadType", c.protocol_) } urls += "?" + c.urlParams_.Encode() body = new(bytes.Buffer) ctype := "application/json" if c.protocol_ != "resumable" { cancel := gensupport.ConditionallyIncludeMedia(c.media_, &body, &ctype) defer cancel() } req, _ := http.NewRequest("POST", urls, body) googleapi.Expand(req.URL, map[string]string{ "groupId": c.groupId, }) if c.protocol_ == "resumable" { if c.mediaType_ == "" { c.mediaType_ = gensupport.DetectMediaType(c.resumable_) } req.Header.Set("X-Upload-Content-Type", c.mediaType_) } req.Header.Set("Content-Type", ctype) req.Header.Set("User-Agent", c.s.userAgent()) if c.ctx_ != nil { return ctxhttp.Do(c.ctx_, c.s.client, req) } return c.s.client.Do(req) }
func (c *FilesUpdateCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } ctype := "application/json" c.urlParams_.Set("alt", alt) urls := googleapi.ResolveRelative(c.s.BasePath, "files/{id}") if c.media_ != nil || c.resumable_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) c.urlParams_.Set("uploadType", c.protocol_) } urls += "?" + c.urlParams_.Encode() if c.protocol_ != "resumable" { cancel := gensupport.ConditionallyIncludeMedia(c.media_, &body, &ctype) defer cancel() } req, _ := http.NewRequest("PUT", urls, body) googleapi.Expand(req.URL, map[string]string{ "id": c.id, }) if c.protocol_ == "resumable" { if c.mediaType_ == "" { c.mediaType_ = gensupport.DetectMediaType(c.resumable_) } req.Header.Set("X-Upload-Content-Type", c.mediaType_) } req.Header.Set("Content-Type", ctype) req.Header.Set("User-Agent", c.s.userAgent()) if c.ctx_ != nil { return ctxhttp.Do(c.ctx_, c.s.client, req) } return c.s.client.Do(req) }