Skip to content

Commit

Permalink
Added raw payload.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbanzon committed Apr 17, 2014
1 parent 7e257c0 commit fda8fd0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions payloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type Payload interface {
GetContentType() string
}

type RawPayload struct {
Data []byte
}

type FormDataPayload struct {
contentType string
Values []keyValuePair
Expand All @@ -36,6 +40,23 @@ type UrlEncodedPayload struct {
Values []keyValuePair
}

func NewRawPayload(data []byte) *RawPayload {
return &RawPayload{Data: data}
}

func (r *RawPayload) GetPayloadBuffer() (*bytes.Buffer, error) {
data := &bytes.Buffer{}
c, err := data.Write(r.Data)
if c != len(r.Data) || err != nil {
return data, err
}
return data, nil
}

func (r *RawPayload) GetContentType() string {
return ""
}

func NewFormDataPayload() *FormDataPayload {
return &FormDataPayload{}
}
Expand Down

0 comments on commit fda8fd0

Please sign in to comment.