我想知道如何从 volley android 中的标题获取默认内容类型
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authkey", Agent_Name);
headers.put("apptype", "android");
headers.put("apptoken", gcmID);
return headers;
}
这里我没有提到内容类型,所以如何获取默认内容类型。
最佳答案
I just append text fields to the body and created the following function to do it in multipart :
private void buildTextPart(DataOutputStream dataOutputStream, String
parameterName, String parameterValue) throws IOException {
dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"");
dataOutputStream.write(parameterName.getBytes("UTF-8"));
dataOutputStream.writeBytes(lineEnd);
dataOutputStream.writeBytes("Content-Type: text/plain; charset=UTF-8" +
lineEnd);
dataOutputStream.writeBytes(lineEnd);
dataOutputStream.write(parameterValue.getBytes("UTF-8"));
dataOutputStream.writeBytes(lineEnd)
}
here mention multipart data format ,and text format as utf8,its working fine
关于android - 如何获取默认内容类型 Android Volley ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654996/