Scorpiion / vane

Server-side framework for Dart/Dartlang with a built-in middleware system.
BSD 3-Clause "New" or "Revised" License
58 stars 11 forks source link

Sending json data with a GET request results in stacktrace #14

Closed andreasolund closed 7 years ago

andreasolund commented 10 years ago

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.

Scorpiion commented 7 years ago

Hello, thanks for the bug report! This is now fixed and published. :+1: