Skip to content

Unable to send post form using http Library because of call of Uri.encodeQueryComponent with 2 parameters instead 1 ... #12

Description

@DartBot

<img src="https://avatars.githubusercontent.com/u/6410144?v=3" align="left" width="96" height="96"hspace="10"> Issue by ioull
Originally opened as dart-lang/sdk#16131


What steps will reproduce the problem?
create a dart file like this :
import 'package:http/http.dart' as http;

main() {
  http.post('http://httpbin.org/post', body: {'key1': 'value1', 'key2': 'value2'}).then((response) {
    print("Response status: ${response.statusCode}");
    print("Response body: ${response.body}");
  });
}

What is the expected output? What do you see instead?
I expect to get a request with form data ... BUT i got
Unhandled exception:
No static method 'encodeQueryComponent' declared in class 'Uri'.

NoSuchMethodError: incorrect number of arguments passed to method named 'encodeQueryComponent'
Receiver: Type: class 'Uri'
Tried calling: encodeQueryComponent("key1", encoding: Instance of 'Utf8Codec')
Found: encodeQueryComponent(String)

­0 _rootHandleUncaughtError.<anonymous closure>.<anonymous closure> (dart:async/zone.dart:677)

­1 _asyncRunCallback (dart:async/schedule_microtask.dart:18)

­2 _asyncRunCallback (dart:async/schedule_microtask.dart:21)

­3 _createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:11)

­4 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:151)

­5 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)

­6 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)

­7 _Timer._createTimerHandler.<anonymous closure> (timer_impl.dart:166)

­8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:93)

What version of the product are you using? On what operating system?
http-0.9.2+1 library

Please provide any additional information below.

Activity

  1. DartBot commented on Jun 5, 2015

    @DartBot
    Author

    <img src="https://avatars.githubusercontent.com/u/6410144?v=3" align="left" width="48" height="48"hspace="10"> Comment by ioull


    After exchange on #irc channel It seems that pubspec of the http package wasn't updated to require an sdk > 1.1 !

    [11:33] <ioull_> Indead the method Uri.encodeQueryComponent is declared with only one parameter but it is called with 2 parameters in http lib
    [11:34] <floitsch> To clarify: you are using the http package v0.9.2+1 ?
    [11:34] <floitsch> what sdk do you use?
    [11:36] <ioull_> sorry : Dart SDK version 1.0.0.10_r30798
    [11:37] <floitsch> The bleeding-edge version of encodeQueryComponent allows two arguments.
    [11:37] <floitsch> I'm guessing the pubspec of the http package wasn't updated to require an sdk > 1.0
    [11:38] <floitsch> ioull_: two things you can do.
    [11:38] <ioull_> OK ! So I need update my sdk or downgrade my http lib ;-)
    [11:38] <floitsch> 1. downgrade to an earlier http package. (specify in the pubspec file which version you want)
    [11:38] <floitsch> 2. upgrade the sdk.

  2. DartBot commented on Jun 5, 2015

    @DartBot
    Author

    <img src="https://avatars.githubusercontent.com/u/8631949?v=3" align="left" width="48" height="48"hspace="10"> Comment by floitschG


    dart-lang/sdk@a8a3c2a introduced usage of encodeQueryComponent with two arguments, but didn't update the pubspec file.

    https://codereview.chromium.org/102973002/diff/1/pkg/http/lib/src/utils.dart


    cc @nex3.
    Added Area-Pkg, Triaged labels.

  3. added
    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)
    P3A lower priority bug or feature request
    on Jun 5, 2015
  4. DartBot commented on Jun 5, 2015

    @DartBot
    Author

    <img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


    We as a team need to talk about how to handle packages' SDK constraints in general. It's not feasible for every package to track down the minimum SDK version that supports every feature used in a package.


    Added Started label.

  5. DartBot commented on Jun 5, 2015

    @DartBot
    Author

    <img src="https://avatars.githubusercontent.com/u/5479?v=3" align="left" width="48" height="48"hspace="10"> Comment by sethladd


    Hi,

    This is marked as Started. Are we still working on it?


    Removed Priority-Unassigned label.
    Added Priority-Low, Pkg-Http labels.

  6. DartBot commented on Jun 5, 2015

    @DartBot
    Author

    <img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


    The http package now has an appropriate SDK constraint.


    Added Fixed label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requesttype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions