request16.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // +build !go1.7
  2. // Copyright (c) 2015-2019 Jeevanandam M (jeeva@myjeeva.com)
  3. // 2016 Andrew Grigorev (https://github.com/ei-grad)
  4. // All rights reserved.
  5. // resty source code and usage is governed by a MIT style
  6. // license that can be found in the LICENSE file.
  7. package resty
  8. import (
  9. "bytes"
  10. "encoding/json"
  11. "net/http"
  12. "net/url"
  13. "time"
  14. )
  15. // Request type is used to compose and send individual request from client
  16. // go-resty is provide option override client level settings such as
  17. // Auth Token, Basic Auth credentials, Header, Query Param, Form Data, Error object
  18. // and also you can add more options for that particular request
  19. type Request struct {
  20. URL string
  21. Method string
  22. Token string
  23. QueryParam url.Values
  24. FormData url.Values
  25. Header http.Header
  26. Time time.Time
  27. Body interface{}
  28. Result interface{}
  29. Error interface{}
  30. RawRequest *http.Request
  31. SRV *SRVRecord
  32. UserInfo *User
  33. isMultiPart bool
  34. isFormData bool
  35. setContentLength bool
  36. isSaveResponse bool
  37. notParseResponse bool
  38. jsonEscapeHTML bool
  39. outputFile string
  40. fallbackContentType string
  41. pathParams map[string]string
  42. client *Client
  43. bodyBuf *bytes.Buffer
  44. multipartFiles []*File
  45. multipartFields []*MultipartField
  46. }
  47. func (r *Request) addContextIfAvailable() {
  48. // nothing to do for golang<1.7
  49. }
  50. func (r *Request) isContextCancelledIfAvailable() bool {
  51. // just always return false golang<1.7
  52. return false
  53. }
  54. // for !go1.7
  55. var noescapeJSONMarshal = json.Marshal