Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http post not sending body on iOS #1343

Closed
tejainece opened this issue Jan 22, 2016 · 22 comments
Closed

Http post not sending body on iOS #1343

tejainece opened this issue Jan 22, 2016 · 22 comments
Assignees
Milestone

Comments

@tejainece
Copy link

Map lMap = {"Foo1": "Bar1", "Foo2": "Bar2"};
String lData = JSON.encode(lMap);  

Map lHeaders = {"Content-type": "application/json", "Accept": "application/json"};

http.Response lResp = await http.post(lUrl, body: lData, headers: lHeaders);

The body is empty.

PS: Also missing the cozy network tab in DevTools in chromium.

@abarth
Copy link
Contributor

abarth commented Jan 22, 2016

/cc @collinjackson

@tejainece
Copy link
Author

Can I get an ETA on this?

@eseidelGoogle
Copy link
Contributor

Attempting to repro now.

eseidelGoogle added a commit to eseidelGoogle/repro_flutter_1343 that referenced this issue Jan 22, 2016
@eseidelGoogle
Copy link
Contributor

@eseidelGoogle
Copy link
Contributor

Android is complaining with
android: I/flutter : NetworkService unavailable MojoInternalError: Failed to register the MojoHandle.
I'm not sure what that means yet. @collinjackson @mpcomplete

@eseidelGoogle
Copy link
Contributor

So I'm not yet able to get as far as @tejainece did. I wonder if there is a regression on master.

@eseidelGoogle
Copy link
Contributor

OK. I have it working on Android. Checking iOS. Ran into #1345 (our iOS workflow still needs a ton of work).

@eseidelGoogle
Copy link
Contributor

OK. I've confirmed this bug on iOS. See https://github.com/eseidelGoogle/repro_flutter_1343/blob/master/README.md

@eseidelGoogle eseidelGoogle added the platform-ios iOS applications specifically label Jan 22, 2016
@eseidelGoogle eseidelGoogle changed the title Http post not sending body Http post not sending body on iOS Jan 22, 2016
@eseidelGoogle eseidelGoogle added this to the Hackathon milestone Jan 22, 2016
@eseidelGoogle
Copy link
Contributor

Yup. It appears the iOS code doesn't use the body parameter at all. :/

https://github.com/flutter/engine/blob/master/sky/services/ns_net/url_loader_impl.mm

So the real bug here is that we don't have any testing of our http library. The dart http library appears to have tests, maybe we can just run them:
https://github.com/dart-lang/http

@eseidelGoogle
Copy link
Contributor

@chinmaygarde has offered to write the missing body code. I expect we'll have this fixed today.

@eseidelGoogle
Copy link
Contributor

The android version only supports a single part body. We can do the same on iOS:
https://github.com/flutter/engine/blob/master/sky/services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java#L161

@eseidelGoogle
Copy link
Contributor

I think Android is also hard-coding the content type which is wrong:
https://github.com/flutter/engine/blob/master/sky/services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java#L189

@eseidelGoogle
Copy link
Contributor

I'm not sure this can be closed yet. There is still an issue of android hard-coding the content type which is causing android to post with 'form=' instead of 'data=' in this example. At least that's my understanding. Can you confirm @tejainece?

@eseidelGoogle eseidelGoogle reopened this Jan 26, 2016
@tejainece
Copy link
Author

I am sorry. I am in a training, so don't have access to my Linux and mac machines. Will test it as soon as i get back home on Thursday.

Thanks for quick response.

@tejainece
Copy link
Author

It doesn't work yet. It still sends empty body.

Maybe I don't have the recent version. I did flutter upgrade. How do I verify it?

@collinjackson collinjackson reopened this Jan 28, 2016
@chinmaygarde
Copy link
Member

I am not able to reproduce this. Can you try removing the ios/ directory and try flutter ios --init again (after the flutter upgrade that you have already done.)

@tejainece
Copy link
Author

I am testing it on Android, not ios. But sure, I will try that.

@tejainece
Copy link
Author

Working on Android now. Thanks :)

@sethladd
Copy link
Contributor

sethladd commented Feb 1, 2016

Cool, thanks for testing!

@mit-mit mit-mit added prod: http and removed plugin labels Feb 2, 2017
@bennybat50
Copy link

bennybat50 commented Nov 1, 2018

final Map<String,dynamic>userData={
      'firstname': _firstNameField,
      'lastname': _lastNameField,
      'display_name': _userNameField,
      'email': _emailField,
      'password': _passwordField
    };

    final response = await http.post(url, body:json.encode(userData) );

I tried sending a post request but its sending an empty body to the server how do i resolve this

@eseidelGoogle
Copy link
Contributor

@bennybat50 would you be willing to open a new bug with more info (e.g. your flutter version information, etc?) . Thanks!

TahaTesser pushed a commit to NevercodeHQ/flutter that referenced this issue Aug 13, 2020
@github-actions
Copy link

github-actions bot commented Sep 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants