Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	velocity/src/androidTest/java/com/rw/velocity/ExampleInstrumentedTest.java
#	velocity/src/main/java/com/rw/velocity/RequestBuilder.java
  • Loading branch information
Ravindu committed Aug 24, 2018
2 parents 4b9b802 + 7c1edbe commit 95a55ff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions velocity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 5
versionName "1.0.5"
versionCode 6
versionName "1.0.6"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
19 changes: 9 additions & 10 deletions velocity/src/main/java/com/rw/velocity/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.SystemClock;
import android.util.Pair;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
Expand Down Expand Up @@ -110,8 +111,8 @@ void setupRequestHeaders()

if (!mBuilder.headers.isEmpty())
{
for (String key : mBuilder.headers.keySet())
mConnection.setRequestProperty(key, mBuilder.headers.get(key));
for (Pair<String, String> p : mBuilder.headers)
mConnection.setRequestProperty(p.first, p.second);
}
}

Expand All @@ -137,15 +138,13 @@ void setupRequestBody() throws IOException
if(mBuilder.contentType != null && mBuilder.contentType.equalsIgnoreCase(Velocity.ContentType.FORM_DATA_MULTIPART.toString()))
{
DataOutputStream dos = new DataOutputStream(mConnection.getOutputStream());
for(String param : mBuilder.params.keySet())
for(Pair<String, String> p : mBuilder.params)
{
String val = mBuilder.params.get(param);

dos.writeBytes(Velocity.Settings.TWOHYPHENS + Velocity.Settings.BOUNDARY + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Disposition: form-data; name=\"" + param + "\"" + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Disposition: form-data; name=\"" + p.first + "\"" + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Type: text/plain" + Velocity.Settings.LINEEND);
dos.writeBytes(Velocity.Settings.LINEEND);
dos.writeBytes(val);
dos.writeBytes(p.second);
dos.writeBytes(Velocity.Settings.LINEEND);
}

Expand All @@ -171,16 +170,16 @@ private String getFormattedParams() throws UnsupportedEncodingException
StringBuilder params = new StringBuilder();
boolean first = true;

for (String key : mBuilder.params.keySet())
for (Pair<String, String> p : mBuilder.params)
{
if (first)
first = false;
else
params.append("&");

params.append(URLEncoder.encode(key, "UTF-8"));
params.append(URLEncoder.encode(p.first, "UTF-8"));
params.append("=");
params.append(URLEncoder.encode(mBuilder.params.get(key), "UTF-8"));
params.append(URLEncoder.encode(p.second, "UTF-8"));
}

return params.toString();
Expand Down
9 changes: 4 additions & 5 deletions velocity/src/main/java/com/rw/velocity/UploadRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Pair;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
Expand Down Expand Up @@ -99,15 +100,13 @@ void setupRequestBody() throws IOException


//write other form data
for(String param : mBuilder.params.keySet())
for(Pair<String, String> p : mBuilder.params)
{
String val = mBuilder.params.get(param);

dos.writeBytes(Velocity.Settings.TWOHYPHENS + Velocity.Settings.BOUNDARY + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Disposition: form-data; name=\"" + param + "\"" + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Disposition: form-data; name=\"" + p.first + "\"" + Velocity.Settings.LINEEND);
dos.writeBytes("Content-Type: text/plain" + Velocity.Settings.LINEEND);
dos.writeBytes(Velocity.Settings.LINEEND);
dos.writeBytes(val);
dos.writeBytes(p.second);
dos.writeBytes(Velocity.Settings.LINEEND);
}

Expand Down
9 changes: 5 additions & 4 deletions velocity/src/main/java/com/rw/velocity/Velocity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Pair;

import java.net.HttpURLConnection;
import java.util.ArrayList;
Expand Down Expand Up @@ -188,13 +189,13 @@ public static class Response
public final String fullUrl;

public @Nullable
final HashMap<String, String> requestHeaders;
final ArrayList<Pair<String, String>> requestHeaders;
public @Nullable
final HashMap<String, String> formData;
final ArrayList<Pair<String, String>> formData;
public @Nullable
final String requestBody;
final String requestBody;
public @Nullable
final String requestMethod;
final String requestMethod;

Response(int requestId,
@NonNull String body,
Expand Down

0 comments on commit 95a55ff

Please sign in to comment.