New library for HTTP Request making released for Robot Framework to Maven Central

2,580 views
Skip to first unread message

Hi-Fi

unread,
Jan 23, 2017, 1:07:36 AM1/23/17
to robotframework-users
There has been couple possibilities to test HTTP requests using Python based libraries (e.g. Requests and HttpLibrary). 

To make testing of HTTP requests easier also in Java environment and with Gradle/Maven, there's new library which utilizes Apache HTTPclient and is available at Maven Central.


In keyword sense library is almost same than Requests, so change of library would be quite easy if that's needed.


Release 1.x.x is pending for Proxy support, timeout setting and also some testing in real projects to see if there's glitches.

David

unread,
Jan 23, 2017, 6:37:32 PM1/23/17
to robotframework-users
I think you should mention the maven link on the GH readme, maybe even embed (into the readme) the mvn details to add to pom.xml so that those who don't want to clone and compile manually can just add to their mvn project, or directly download the binaries.

Hi-Fi

unread,
Jan 25, 2017, 12:28:06 AM1/25/17
to robotframework-users
Will do that, thank you for comment.

Marat Kalibekov

unread,
Jan 25, 2017, 1:25:14 AM1/25/17
to juho.s...@gmail.com, robotframework-users
--


You received this message because you are subscribed to the Google Groups "robotframework-users" group.


To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.


To post to this group, send email to robotframe...@googlegroups.com.


Visit this group at https://groups.google.com/group/robotframework-users.


For more options, visit https://groups.google.com/d/optout.


toukopouko

unread,
Sep 26, 2017, 3:41:57 AM9/26/17
to robotframework-users
Hi,

Tried to take this library in to use. Added it to pom.xml but when defining the library like:

Library HttpRequestLibrary

I'm getting error:

Getting keyword names from library 'HttpRequestLibrary' failed: Calling dynamic method 'getKeywordNames' failed: NoClassDefFoundError: com/google/gson/JsonSyntaxException

Any idea whats wrong?

Hi-Fi

unread,
Sep 27, 2017, 12:23:18 AM9/27/17
to robotframework-users
Hi,

Which version you used, and did you had something else in pom.xml, too?

toukopouko

unread,
Oct 24, 2017, 10:37:20 AM10/24/17
to robotframework-users


On Wednesday, 27 September 2017 07:23:18 UTC+3, Hi-Fi wrote:
Hi,

Which version you used, and did you had something else in pom.xml, too?


Returned back to this and tried this again, this time there was no such problem and could not reproduce the problem. However, I encountered an new problem. If a post request contains  any special characters like "ä" in data part, they will not be encoded properly. They will go to the webservice as -characters.

This character problem did not occur with python based requests library (https://github.com/bulkan/robotframework-requests) which was used before switching to this.

Any ideas?

Hi-Fi

unread,
Oct 25, 2017, 12:39:52 AM10/25/17
to robotframework-users
I have to check this, currently tests have included only 'boring' ASCII characters. Although I thought it would be UTF8 through the codebase.

Some things that come to mind (just guesses without code check):
- test case file encoding
- server side encoding (If not told explicitly in headers)

toukopouko

unread,
Oct 25, 2017, 3:53:55 AM10/25/17
to robotframework-users
Re-tested that with old python library there is no problem, only with this new library. Another post request with json format data which has "ä' letter is getting response:

JBWEB000065: HTTP Status 400 - org.codehaus.jackson.JsonParseException: Invalid UTF-8 middle byte 0x6b

Hi-Fi

unread,
Oct 28, 2017, 7:52:03 AM10/28/17
to robotframework-users
Issue at Github: https://github.com/Hi-Fi/robotframework-httprequestlibrary/issues/35

Normal post at least goes as should, and following test case passes:
Post Requests
    Create Session  httpbin  http://httpbin.org
    &{data}=  Create Dictionary  name=bulkan  surname=evcimen    utf-text=ääkköstesti
    &{headers}=  Create Dictionary  Content-Type=application/x-www-form-urlencoded
    ${resp}=  Post Request  httpbin  /post  data=${data}  headers=${headers}
    Log  ${resp.json}
    Dictionary Should Contain Value  ${resp.json['form']}  bulkan
    Dictionary Should Contain Value  ${resp.json['form']}  evcimen
    Dictionary Should Contain Value  ${resp.json['form']}  ääkköstesti

Can you share the test case/similar test case that shows the error? It might be, that Apache HTTPclient doesn't add by default e.g. some encoding header, which is added by Python's requests -library.

Br,
Juho 

Hi-Fi

unread,
Oct 28, 2017, 8:46:35 AM10/28/17
to robotframe...@googlegroups.com
By default headers seems to be (relevant part):
Accept-Encoding gzip,deflate
User-Agent Apache-HttpClient/4.5.2 (Java/1.8.0_144)
Content-Type text/plain; charset=ISO-8859-1
Connection Keep-Alive

With Python requests library:
Accept-Encoding gzip, deflate
User-Agent python-requests/2.18.4
Connection keep-alive
Accept */*

 Still both show the scandic letters correctly in the SoapUI mock. Maybe server you're using get's confused with that default content type setting? 

Br,
Juho

toukopouko

unread,
Oct 30, 2017, 7:54:34 AM10/30/17
to robotframework-users
Hi,

In my cases I have a textfile with a string in json format in it and pass that text into ${data}, no the data part is not a dictionary. But for example, I think the fault can be seen with a case like this.

    Create Session  httpbin  http://httpbin.org
    ${data}=  Set Variable  ääkköstekstiä on tässä
    &{headers}=  Create Dictionary Content-Type=application/json
    ${resp}=  Post Request  httpbin  /post  data=${data}  headers=${headers}
    Log ${resp.json}
    Log ${resp.content}

toukopouko

unread,
Oct 30, 2017, 8:53:00 AM10/30/17
to robotframework-users
When the same case is ran with python library, the message is unicode encoded:

KEYWORD ${resp} = RequestsLibrary . Post Request httpbin, /post, data=${data}, headers=${headers}
Documentation:

Send a POST request on the session object found using the

Start / End / Elapsed:20171030 14:42:27.319 / 20171030 14:42:28.971 / 00:00:01.652
14:42:27.379INFOStarting new HTTP connection (1): httpbin.org
14:42:28.935DEBUG"POST /post HTTP/1.1" 200 512
14:42:28.962DEBUGpost response: { "args": {}, "data": "\"\\u00e4\\u00e4kk\\u00f6steksti\\u00e4 on t\\u00e4ss\\u00e4\"", "files": {}, "form": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "close", "Content-Length": "54", "Content-Type": "application/json", "Host": "httpbin.org", "User-Agent": "python-requests/2.10.0" }, "json": "\u00e4\u00e4kk\u00f6steksti\u00e4 on t\u00e4ss\u00e4", "origin": "131.207.242.5", "url": "http://httpbin.org/post" }
14:42:28.965INFOPost Request using : alias=httpbin, uri=/post, data="\u00e4\u00e4kk\u00f6steksti\u00e4 on t\u00e4ss\u00e4", headers={u'Content-Type': u'application/json'}, files=None, allow_redirects=True

Hi-Fi

unread,
Nov 2, 2017, 1:45:52 PM11/2/17
to robotframework-users
Thank you, I encoded only FormEntity (Dictionary data) but not StringEntity ("raw" data) to UTF8. This is now fixed, and new version 0.0.9 will be released as soon as httpclient new version (0.0.4) is available at Maven central.

Br,
Juho

toukopouko

unread,
Nov 2, 2017, 2:51:52 PM11/2/17
to robotframework-users
Excellent, thanks!

toukopouko

unread,
Jul 2, 2018, 5:47:32 AM7/2/18
to robotframework-users
We are using this library and getting a lot of following logs to console:

...
*DEBUG* Connection manager is shutting down
*DEBUG* Connection manager shut down
*DEBUG* Connection manager is shutting down
*DEBUG* Connection manager shut down
*DEBUG* Connection manager is shutting down
...

How can we disable these logs?

Hi-Fi

unread,
Jul 3, 2018, 12:31:18 AM7/3/18
to robotframework-users
Currently I think only way is not to use DEBUG logging, as that logging goes also to httpclient (which creates those lines).

Main issue is, that those connection managers messages bypass somehow the normal way to log to Robot's own log file, and lets those pass to STDOUT instead. 

toukopouko

unread,
Jul 3, 2018, 5:14:20 AM7/3/18
to robotframe...@googlegroups.com
Hi,

We are using rf maven plugin 1.4.7 and it does NOT have any effect if I define the logLevel to INFO or anything else in pom.xml, we still get those lines to console.

Hi-Fi

unread,
Jul 4, 2018, 1:34:50 AM7/4/18
to robotframework-users
RF maven plugin doesn't affect here. 

Have you created the session with debug enabled in script? As (I think) only way to get that logging is to create session with debug enabled (code: https://github.com/Hi-Fi/robotframework-httprequestlibrary/blob/master/src/main/java/com/github/hi_fi/httprequestlibrary/keywords/Session.java#L44) which then will create the actual logger at client (code: https://github.com/Hi-Fi/httpclient/blob/master/src/main/java/com/github/hi_fi/httpclient/RestClient.java#L96).


Also, if there's issues with library, please create issue to Github. This is not the issue tracker and especially this thread started from first version of the library is not suitable for Q&A.
Reply all
Reply to author
Forward
0 new messages