Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stub for Network component #17

Merged

Conversation

epicfailname
Copy link

Returns "Hello World" for any given String URL

Returns "Hello World" for any given String URL
Removes the need of having concrete class NetworkManager
Copy link

@thomastanck thomastanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rlrh
Copy link

rlrh commented Feb 23, 2019

Eventually, we will need a method that returns an InputStream, because the Rome library doesn't accept a String but needs an InputStream that can be read by an XmlReader in order to build a SyndFeed.

Refer to:
rometools/rome#276
https://hc.apache.org/httpcomponents-client-ga/quickstart.html
https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/util/EntityUtils.html

Here is a code fragment for future reference:

HttpEntity getEntity(String url) {
  CloseableHttpClient httpclient = HttpClients.createDefault();
  HttpGet httpGet = new HttpGet(url);
  CloseableHttpResponse response = httpclient.execute(httpGet);
  HttpEntity entity = response.getEntity();
  return entity;
}
entity.getContent() // returns InputStream
EntityUtils.toString(entity) // returns String

@epicfailname epicfailname merged commit fcc6ab0 into CS2103-AY1819S2-W10-1:master Feb 23, 2019
@epicfailname epicfailname deleted the add-network-stub branch February 25, 2019 05:49
@thomastanck thomastanck added this to the Mid-v1.1 milestone Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants