Unable to set HTTP Referer Header when request has redirect 30X response

27 views
Skip to first unread message

Anirudh Warrier

unread,
Aug 15, 2020, 12:40:56 AM8/15/20
to Gatling User Group
Hi,

I want to set the Referer header in an HTTP request that has a 301/302 Response.

However, even when it is explicitly set in the HTTP request. the Referer that is actually set is the self URL of the request. Is this expected behavior?

Example:

=========================
setUp(scenario("dummy")
  .exec(
    http("first")
      .get("/")
      .header(HttpHeaderNames.Referer, "https://facebook.com")
    )
  .inject(atOnceUsers(1)))
  .protocols(
    http
      .baseUrl("http://google.com")
      .disableWarmUp
      .disableCaching
)
=========================

Expected Log
=========================
HTTP request:
GET http://google.com/
headers=
Referer: https://facebook.com
accept: */*
host: google.com
=========================

Actual Log

=========================
HTTP request:
GET http://google.com/
headers=
accept: */*
Referer: http://google.com/
host: www.google.com
=========================
HTTP response:
status=
301 Moved Permanently
headers=
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Sat, 15 Aug 2020 03:21:25 GMT
Expires: Mon, 14 Sep 2020 03:21:25 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

body=
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

<<<<<<<<<<<<<<<<<<<<<<<<<

The Referer here for the request is http://google.com/ (same as Base URL + path) even though it was set to https://facebook.com in the HTTP request part.

The only workaround currently is to enable disableFollowRedirect for the request and then follow the redirect manually. However, in my specific use case, I don't want to do that.

Is this expected behavior, or is this a bug?

slan...@gatling.io

unread,
Aug 15, 2020, 2:36:53 AM8/15/20
to gat...@googlegroups.com
This is a bug, thanks for reporting!


Le 15 août 2020 à 06:40, Anirudh Warrier <anirudh...@gmail.com> a écrit :

Hi,
--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/1a1acf98-37e9-48c2-b7fa-4d2e197352a0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages