-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
336 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
unirest/src/main/java/kong/unirest/core/RequestFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package kong.unirest.core; | ||
|
||
class RequestFactory { | ||
public static <R extends BaseRequest> R copy(HttpRequest baseRequest) { | ||
if(baseRequest instanceof HttpRequestNoBody){ | ||
return (R) new HttpRequestNoBody((HttpRequestNoBody)baseRequest); | ||
} | ||
if(baseRequest instanceof HttpRequestBody){ | ||
return (R) new HttpRequestBody((HttpRequestBody)baseRequest); | ||
} | ||
if(baseRequest instanceof HttpRequestUniBody){ | ||
return (R) new HttpRequestUniBody((HttpRequestUniBody)baseRequest); | ||
} | ||
if(baseRequest instanceof HttpRequestMultiPart) { | ||
return (R) new HttpRequestMultiPart((HttpRequestMultiPart)baseRequest); | ||
} | ||
|
||
throw new UnirestException("Cannot find matching type: " + baseRequest.getClass()); | ||
} | ||
} |
Oops, something went wrong.