Back to project page gm-httpengine-eclipse.
The source code is released under:
MIT License
If you think the Android project gm-httpengine-eclipse listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.gemini.parser; /* w w w . j a v a 2s . c o m*/ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Set; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.message.BasicNameValuePair; import org.gemini.net.GMHttpParameters; public class DefaultHttpRequestParser implements HttpRequestParser { /*** * parse form body */ @Override public byte[] parse(GMHttpParameters httpParams) throws IOException { Set<String> keySet = httpParams.getNames(); ArrayList<NameValuePair> nvps = new ArrayList<NameValuePair>(); for (String name : keySet) { String value = httpParams.getStringParameter(name); NameValuePair p = new BasicNameValuePair(name, value); nvps.add(p); } HttpEntity entity = new UrlEncodedFormEntity(nvps, "UTF-8"); InputStream is = entity.getContent(); int avaliable = is.available(); byte[] buffer = new byte[avaliable]; is.read(buffer); is.close(); return buffer; } @Override public String pareContentType() { return "application/x-www-form-urlencoded; charset=UTF-8"; } }