Scorpiion/vane

Sending json data with a GET request results in stacktrace

Closed this issue · 1 comments

When you try to send JSON data with a GET request which obviously isn't recommended/possible; Vane still tries to parse a request which has an empty body.

I've included a sample client and server that should reproduce the issue:

Client

import 'dart:html';
//...
HttpRequest.request("/magrathea", method: "GET",
  requestHeaders: {"Content-Type": "application/json"},
  sendData: '{"name":"Zaphod"}'
).then((response) {
  print(response.responseHeaders);
  print(response.responseText);
})
//...

Server

import 'dart:io';
import 'dart:async';
import 'package:vane/vane.dart';

class MagratheaService extends Vane {
  @Route("/magrathea")
  Future main() {
    print(json);
    return close("OK");
  }
}

We should probably throw an exception that gives developers a hint of what went wrong.

Hello, thanks for the bug report! This is now fixed and published. 👍