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

Confusing: GET http://host/path creates new HTTP Context

Open ravijammi opened this issue 12 years ago • 6 comments

Hi, I am trying to use the latest version of the httplibrary, and i am running into this issue. Even though i try to use "Set Request Header" it does not add them to the request.

Here is one of the snippets:

*** Settings ***

Resource        variables.txt
Library         HttpLibrary.HTTP
Test Setup      Create HTTP Context     ${HOST}
*** Test Cases ***

Simple GET with complete host
    Set Request Header  Content-Type   application/xml
    Set Request Header  Authorization   IAUTH Test
    GET      http://localhost/test
    Log Response Body

Is this an issue, if not please correct me where i am going wrong.

Thanks, Ravi

ravijammi avatar Dec 13 '12 22:12 ravijammi

Hey Ravi,

thanks for this bug report! Here's what happens:

GET                  http://localhost/test

expands internally to

Create HTTP Context  http://localhost/
GET                  /test

and thus — in the new context there are no headers set.

So, to make your test work, you could just drop the "http://localhost" bit of the GET keyword invocation (and move the "Create HTTP Context http://localhost" bit to Test Setup or earlier in the test).

Initially I thought this expansion would make things easier, I'm keeping this ticket open while thinking about whether this still holds true.

peritus avatar Dec 14 '12 06:12 peritus

Yay!! awesome, that worked. Thanks a lot for quickly looking into it.

-Ravi

ravijammi avatar Dec 14 '12 08:12 ravijammi

Hi Peritus, This has been working fine, recently i upgraded to the latest version for robotframework,your library and others as well. Since, then i am getting this error: "gaierror: [Errorno 8] nodename nor servname provided, or not known" Following is one of my snippets:

*** Settings ***
Test Setup        Create HTTP Context    http://localhost:8080
Resource          variables.txt
Library           HttpLibrary.HTTP

*** Test Cases ***
GET with one word request body
    Set Request Header    my_id    1
    Set Request Header    Content-Type    application/json
    Set Request Header    another_id    ABCD
    Set Request Header    yet_another_id    1312232
    GET    /abcd/efgh/ (Getting the error here)
    Log    Response Body

Am I doing anything wrong here?

Thanks, Ravi

ravijammi avatar Mar 15 '13 21:03 ravijammi

@ravijammi this is a different issue.

Googling for "gaierror" raises this: http://docs.python.org/2/library/socket.html#socket.gaierror — probably your DNS server does not resolve localhost to 127.0.0.1.

peritus avatar Mar 16 '13 09:03 peritus

I am also encountering this gaierror alot which is a blocker for my testing.

13:28:41.532 FAIL gaierror: [Errno 8] nodename nor servname provided, or not known Below is my observation

I have around 600 uri in array for which i have to do GET request

. When i place it in for loop and send request one by one. I get response for all 247 uri , when it reaches 248 uri it fails there everytime. I have been googling alot but not able to find any relevant fix that i can put in place.

@ravijammi : Please let me know if you have found any resolution

screen shot 2015-04-13 at 1 39 47 pm

GayanaYJ avatar Apr 13 '15 18:04 GayanaYJ

this

Hey Ravi,

thanks for this bug report! Here's what happens:

GET                  http://localhost/test

expands internally to

Create HTTP Context  http://localhost/
GET                  /test

and thus — in the new context there are no headers set.

So, to make your test work, you could just drop the "http://localhost" bit of the GET keyword invocation (and move the "Create HTTP Context http://localhost" bit to Test Setup or earlier in the test).

Initially I thought this expansion would make things easier, I'm keeping this ticket open while thinking about whether this still holds true.

Your answer save my day :)

wutingbupt avatar Dec 13 '19 08:12 wutingbupt