mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 23:58:44 +05:00
Changed consts in utils
This commit is contained in:
committed by
Dan Christian Bogos
parent
8bcbd789e6
commit
4883754cf0
@@ -57,7 +57,7 @@ func HTTPPostJSON(url string, content []byte) (respBody []byte, err error) {
|
||||
// NewHTTPPoster return a new HTTP poster
|
||||
func NewHTTPPoster(replyTimeout time.Duration, addr, contentType string,
|
||||
attempts int) (httposter *HTTPPoster, err error) {
|
||||
if !utils.SliceHasMember([]string{utils.CONTENT_FORM, utils.ContentJSON, utils.CONTENT_TEXT}, contentType) {
|
||||
if !utils.SliceHasMember([]string{utils.ContentForm, utils.ContentJSON, utils.ContentText}, contentType) {
|
||||
return nil, fmt.Errorf("unsupported ContentType: %s", contentType)
|
||||
}
|
||||
return &HTTPPoster{
|
||||
@@ -124,7 +124,7 @@ func (pstr *HTTPPoster) do(req *http.Request) (respBody []byte, err error) {
|
||||
|
||||
func (pstr *HTTPPoster) getRequest(content interface{}, hdr http.Header) (req *http.Request, err error) {
|
||||
var body io.Reader
|
||||
if pstr.contentType == utils.CONTENT_FORM {
|
||||
if pstr.contentType == utils.ContentForm {
|
||||
body = strings.NewReader(content.(url.Values).Encode())
|
||||
} else {
|
||||
body = bytes.NewBuffer(content.([]byte))
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestHttpBytesPoster(t *testing.T) {
|
||||
content := []byte(`Test
|
||||
Test2
|
||||
`)
|
||||
pstr, err := NewHTTPPoster(2*time.Second, "http://localhost:8080/invalid", utils.CONTENT_TEXT, 3)
|
||||
pstr, err := NewHTTPPoster(2*time.Second, "http://localhost:8080/invalid", utils.ContentText, 3)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user