Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Represents an HTTP header - a key/value pair of meta-information about a request.
Properties
key
key: string;
Key of the HTTP header.
Type: string
Notes:
- This property can be edited in early-execution mode.
value
value: minecraftserveradmin.SecretString | string;
Value of the HTTP header.
Type: @minecraft/server-admin.SecretString | string
Notes:
- This property can be edited in early-execution mode.
Methods
constructor
new HttpHeader(key: string, value: minecraftserveradmin.SecretString | string)
Parameters
- key: string
- value: @minecraft/server-admin.SecretString | string
Returns HttpHeader
Examples
simpleHttpRequest.ts
import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
async function updateScore() {
const req = new HttpRequest('http://localhost:3000/updateScore');
req.body = JSON.stringify({
score: 22,
});
req.method = HttpRequestMethod.Post;
req.headers = [
new HttpHeader('Content-Type', 'application/json'),
new HttpHeader('auth', 'my-auth-token'),
];
await http.request(req);
}
(preview) Work with this sample on the MCTools.dev code sandbox.