[ 
https://issues.apache.org/jira/browse/QUARKS-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15276887#comment-15276887
 ] 

ASF GitHub Bot commented on QUARKS-96:
--------------------------------------

Github user dlaboss commented on a diff in the pull request:

    https://github.com/apache/incubator-quarks/pull/106#discussion_r62559569
  
    --- Diff: 
connectors/http/src/main/java/quarks/connectors/http/HttpStreams.java ---
    @@ -38,12 +40,88 @@ Licensed to the Apache Software Foundation (ASF) under 
one
      */
     public class HttpStreams {
         
    +    /**
    +     * Make an HTTP GET request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the stream, 
    +     * HTTP GET request is executed on provided uri. As a result, Response 
is added to
    +     * the response TStream.
    +     * <br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     JsonObject request1 = new JsonObject();
    +     *     request1.addProperty("a", "abc");
    +     *     request1.addProperty("b", "42");
    +     *     TStream<JsonObject> rc = HttpStreams.getJson(
    +     *             topology.collection(Arrays.asList(request1)),
    +     *             HttpClients::noAuthentication,
    +     *             t -> url + "a=" + t.get("a").getAsString() + "&b="
    +     *                     + t.get("b").getAsString());
    +     * }
    +     * </pre>
    +     * <br>
    +     * See <i>HttpTest</i> for example.
    +     * <br>
    +     * @param stream - JsonObject TStream.
    +     * @param clientCreator - CloseableHttpClient supplier preferably 
created using {@link HttpClients}
    +     * @param uri - URI function which returns URI string
    +     * @return TStream of JsonObject which contains responses of GET 
requests
    +     * 
    +     * @see HttpStreams#requests(TStream, Supplier, Function, Function, 
BiFunction)
    +     */
         public static TStream<JsonObject> getJson(TStream<JsonObject> stream,
                 Supplier<CloseableHttpClient> clientCreator,
                 Function<JsonObject,String> uri) {
             
             return HttpStreams.<JsonObject,JsonObject>requests(stream, 
clientCreator,
    -                t -> HttpGet.METHOD_NAME, uri, HttpResponders.json());
    +            t -> HttpGet.METHOD_NAME, uri, HttpResponders.json());
    +    }
    +    
    +    /**
    +     * Make an HTTP POST request with JsonObject. <br>
    +     * 
    +     * Method specifically works with JsonObjects. For each JsonObject in 
the stream, 
    +     * HTTP POST request is executed on provided uri. Request body is 
filled using
    +     * HttpEntity provided by body function. As a result, Response is 
added to
    +     * the response TStream.<br>
    +     * 
    +     * Sample usage:<br>
    +     * 
    +     * <pre>
    +     * {@code
    +     *     JsonObject request = new JsonObject();
    +     *     request.addProperty("a", "abc");
    --- End diff --
    
    Given the getJson() example I was sort of expecting that the "a" and "b" 
json properties would be used in forming the url.  Maybe tweak this example to 
rename the properties or to use them the same way?  Same `url` var comment as 
above.


> Add an HTTP POST utility method.
> --------------------------------
>
>                 Key: QUARKS-96
>                 URL: https://issues.apache.org/jira/browse/QUARKS-96
>             Project: Quarks
>          Issue Type: Improvement
>          Components: Connectors
>            Reporter: Daniel John Debrunner
>            Assignee: Dale LaBossiere
>              Labels: newbie
>
> HTTPStreams.requests can support any type of request but it would be useful 
> to have a utility method for POST requests, similar to getJson - i.e., a 
> postJson()



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to