robotframework-httplibrary icon indicating copy to clipboard operation
robotframework-httplibrary copied to clipboard

Http Request sends wrong HTTP ?

Open ybilik opened this issue 11 years ago • 2 comments

Hello,

I have done the following tests (with httplibrary 0.4.2). Both should return the same response, but the GET answer is a HTTP status 302 (as expected), while the Http Request answer is 400:

*** Settings *** Library HttpLibrary.HTTP

*** Test Cases *** With GET Test Create Http Context www.facebook.com http Next Request May Not Succeed GET / Log Response Status Log Response Headers Log Response Body Restore Http Context

With Http Request Test Create Http Context www.facebook.com http Next Request May Not Succeed Http Request GET / Log Response Status Log Response Headers Log Response Body Restore Http Context

I ran into Wireshark to look at the sent requests, and it seems (not sure as I am not familiar with wireshark) that Facebook feels angry because when using the "Http Request" keyword, the Host header is set to localhost:80 instead of www.facebook.com.

I got this bug because originally, I had a problem with https requests: here again, I am not sure, but it seems that the "Http Request" keyword always use the http scheme, even if I set it to https with a call to "Create Http Context".

ybilik avatar Aug 08 '14 09:08 ybilik

I investigated issues related to Http Request. Conclusion:

  1. Http Request does not send HTTP headers at all.

Actual result: Following headers are missing: Date-Iso:Testing Authorization:Testing Userid:[email protected] Apache log after OPTIONS request by Http Request: +9819:572ef840:6|OPTIONS /edtest HTTP/1.1|Accept-Encoding:identity|Host:localhost%3a80|Content-Length:0 -9819:572ef840:6 Expected result: Fixed OPTIONS method

+9820:572ef92b:c|OPTIONS /edtest HTTP/1.1|Accept-Encoding:identity|Date-Iso:Testing|Host:localhost|Authorization:Testing|Userid:[email protected]|Content-Length:0

  1. Affected method is https://github.com/peritus/robotframework-httplibrary/blob/master/src/HttpLibrary/init.py#L187
  2. There is a workaround:

Fixed method for OPTIONS added into init.py:

def OPTIONS(self, url):
        path = self._path_from_url_or_path(url)
        self.context.pre_process_request()
        logger.debug("Performing OPTIONS request on %s://%s%s" % (
            self.context._scheme, self.app.host, path))
        self.context.post_process_request(
            self.app.options(path, self.context.request_headers)
        )

vikulin avatar May 08 '16 08:05 vikulin

Any updates here?

vikulin avatar Jun 03 '16 12:06 vikulin