Comments (4)
https://www.iana.org/assignments/media-types/application/octet-stream
The "octet-stream" subtype is used to indicate that a body contains
arbitrary binary data.
from sdk-javascript.
Code to send the CloudEvent message.
package cloudevents_test
import (
"context"
"testing"
"time"
"github.com/cloudevents/sdk-go"
"github.com/cloudevents/sdk-go/pkg/cloudevents/client"
cehttp "github.com/cloudevents/sdk-go/pkg/cloudevents/transport/http"
"github.com/cloudevents/sdk-go/pkg/cloudevents/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
func TestTransportHTTP(t *testing.T) {
encodeType := "application/octet-stream"
event := cloudevents.Event{
Context: cloudevents.EventContextV02{
ID: uuid.New().String(),
Type: "example",
Source: *types.ParseURLRef("/test"),
Time: &types.Timestamp{Time: time.Now()},
ContentType: &encodeType,
Extensions: map[string]interface{}{"a": 1, "b": 2, "c": 3},
}.AsV02(),
Data: []byte("Hello text."),
DataEncoded: true,
}
c, err := newEventClient("http://127.0.0.1:3000")
assert.NoError(t, err)
resp, err := c.Send(context.Background(), event)
assert.NoError(t, err)
t.Log(resp)
}
func newEventClient(target string) (client.Client, error) {
t, err := cehttp.New([]cehttp.Option{
cehttp.WithBinaryEncoding(), cehttp.WithTarget(target),
}...)
if err != nil {
return nil, err
}
c, err := client.New(t, client.WithUUIDs(), client.WithTimeNow())
if err != nil {
return nil, err
}
return c, nil
}
from sdk-javascript.
@pengsrc,
Nice PR!
from sdk-javascript.
@pengsrc
Released: https://www.npmjs.com/package/cloudevents-sdk/v/0.2.6
from sdk-javascript.
Related Issues (20)
- Binary mode header missing extension attribute when the value is false (boolean)
- Validation is broken HOT 1
- Issue converting a golang cloudevents type Kafka message HOT 3
- Unnecessary polyfill for http and https required HOT 3
- Harmonize validation of CloudEvents HOT 9
- Avoid jest#13535 and planttheidea/fast-equals#91
- [security] Potential XSS in httpTransport() HOT 3
- Does not work in browsers as of 5.3.1 HOT 1
- Add the engines property to the package.json HOT 1
- Add Tests for the Browser version HOT 2
- No .d.ts files available for browser bundle HOT 1
- Add Test Runner for Node 18 LTS HOT 1
- Can't resolve 'http' error when using on React app HOT 11
- Vulnerability of util version 0.12.5 HOT 2
- Invalid default data for parsing in binary mode HOT 7
- Getting error when installing on node 20.0.0
- Compatible with Node 20.x HOT 1
- Add support for request timeout in HTTP transport HOT 2
- HTTP headers name case for extensions HOT 3
- Unable to retrieve data from the HTTP request HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-javascript.