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

URLEncodedUtils and NameValuePair shouldn't be here #19

Open
ryanhoo opened this issue Mar 25, 2016 · 1 comment
Open

URLEncodedUtils and NameValuePair shouldn't be here #19

ryanhoo opened this issue Mar 25, 2016 · 1 comment

Comments

@ryanhoo
Copy link

ryanhoo commented Mar 25, 2016

There are only a few lines of code which use http-client's related APIs: URLEncodedUtils & NameValuePair.

List<NameValuePair> query = URLEncodedUtils.parse(parsedUri, "utf-8");

for (NameValuePair pair : query) {
    routerParams.openParams.put(pair.getName(), pair.getValue());
}

They shouldn't be here because:

  • It can be easily replaced
  • MultiDex 65k method count limits: http-client has 7521 methods in total. It doesn't seem to be a problem. But think of the limit is 65535, the cost is too much for a small router component.

They can be replaced by Uri. It handles urls such as xxx?key1=val+1&key2=val%202 pretty well.

Uri uri = Uri.parse(url);
Set<String> queryKeys = uri.getQueryParameterNames();
for (String key : queryKeys) {
    routerParams.openParams.put(key, uri.getQueryParameter(key));
}

Sure Uri.getQueryParameterNames() is only available since API 11 and if you want to support API 9, then you can also achive the goal by using Uri.getEncodedQuery(), it's available since API 1. Of course you need to parse the parameters set by your own, but that wouldn't be a problem.

This project uses http-client's API but there seems no jar file nor gradle dependence declared.

It's a nice project but I don't think anyone can run the testcases in this project without too much pain. I was going to make a pull request but I found this project doesn't practice gradle very well. I might need to refactor the whole structure if I want to start to work on this project, I guess.

A nice open source project should be friendly to other programmers, isn't it?

@tanweijiu
Copy link

it's a great idea when someone not uses the httpClient anymore...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants