Amature
November 10, 2014, 4:10pm
1
Hi ,
Could you please tell me if the syntax is correct ?
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.headers(“Content-Type”, “application/json”)
.headers(“sentHeaders”)
.headers(“Accept”,“application/json”)
.headers(“Accept-Charset”,“utf-8n”)
.acceptEncodingHeader(""“gzip, deflate”"")
.acceptLanguageHeader(""“en-us,en;q=0.5"”")
.connection(""“keep-alive”"")
The error which i am getting is attached as a screen shot
Kindly help
.headers() accepts a map. You want .header( name, value )
Not sure what you intend with .headers(“sentHeaders”), but if you intend to send the header without a value, you need to add an empty value, like so: .header(“sentHeaders”,"")
Amature
November 11, 2014, 5:58am
3
HI John,
I have deleted that header and it look like the one mentioned below
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.headers(“Content-Type”, “application/json”)
.headers(“Accept”,“application/json”)
.headers(“Accept-Charset”,“utf-8n”)
.acceptEncodingHeader(""“gzip, deflate”"")
.acceptLanguageHeader(""“en-us,en;q=0.5"”")
.connection(""“keep-alive”"")
But still the same errors pops up.
Kindly help
Amature
November 11, 2014, 9:38am
4
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.util.matching.Regex
import scala.concurrent.duration._
class getSampleTest extends Simulation{
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.headers(“Content-Type”, “application/json”)
.headers(“Accept”,“application/json”)
.headers(“Accept-Charset”,“utf-8n”)
.acceptEncodingHeader(""“gzip, deflate”"")
.acceptLanguageHeader(""“en-us,en;q=0.5"”")
.connection(""“keep-alive”"")
val scn = scenario(“XYZ”)
.group(“XYZ Group”) {
exec(http(“XYZ-Page”).get("/profile/services/countries").check(status.is(200)))
}
setUp(scn.inject(
rampUsersPerSec(1) to(10) during(5),
constantUsersPerSec(10) during(5)
).protocols(httpProtocol))
}
Quoting John : “.headers() accepts a map. You want .header( name, value )”
Change :
.headers(“Content-Type”, “application/json”)
.headers(“Accept”,“application/json”)
.headers(“Accept-Charset”,"utf-8n”)
To :
.header(“Content-Type”, “application/json”)
.header(“Accept”,“application/json”)
.header(“Accept-Charset”,"utf-8n”)
Amature
November 11, 2014, 10:45am
6
Hi ,
just changed a little in the headers part , along with the syntax in headers
val AllHeaders = Map(“Content-Type” → “application/json”, “Accept” → " application/json ")
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.headers(AllHeaders )
.header(""“Accept-Charset”,“utf-8n”"")
.acceptLanguageHeader(""“en-us,en;q=0.5"”")
.acceptEncodingHeader(""“gzip, deflate”"")
.connection(""“keep-alive”"")
But still getting error (Error snapshot attached)
Kindly help
Amature
November 11, 2014, 10:58am
7
hi ,
i have also used the below over here
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.header(“Content-Type”,“application/json”)
.header(“Accept”," application/json ")
.header(“Accept-Charset”,“utf-8n”)
.acceptLanguageHeader(“en-us”,“en;q=0.5”)
.acceptEncodingHeader(“gzip”, “deflate”)
.connection(“keep-alive”)
Getting the error mentioned in snapshot_1
Thanks in Advance
Can you post your full simulation please ?
Amature
November 11, 2014, 4:13pm
10
package simulations.computerdatabase.advanced
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.util.matching.Regex
import scala.concurrent.duration._
class getSampleTest extends Simulation{
val sentHeaders = Map(“Content-Type” → “application/json”, “Accept” → " application/json ")
val httpProtocol = http
.baseURL(“https://xyz.com ”)
.headers(sentHeaders)
.acceptLanguageHeader(“en-us,en;q=0.5”)
.acceptEncodingHeader(“gzip,deflate”)
.connection(“keep-alive”)
val scn = scenario(“XYZ”)
.group(“XYZ Group”) {
exec(http(“XYZ-PAge”).get("/profile/services/countries").check(status.is(200)))
}
setUp(scn.inject(
rampUsersPerSec(1) to(10) during(5),
constantUsersPerSec(10) during(5)
).protocols(httpProtocol))
}
And the Error which i am getting →
gatling-charts-highcharts-2.0.0-SNAPSHOT" 20:50:58.858 [ERROR] i.g.a.ZincCompiler$ - C:\gatling-charts-highcharts-2.0.0-20 140922.162052-88-bundle\gatling-charts-highcharts-2.0.0-SNAPSHOT\user-files\simu lations\computerdatabase\advanced\CPC.scala:30: value headers is not a member of io.gatling.http.config.HttpProtocolBuilder possible cause: maybe a semicolon is missing before `value headers’ ? 20:50:58.863 [ERROR] i.g.a.ZincCompiler$ - .headers(sentHeaders) 20:50:58.864 [ERROR] i.g.a.ZincCompiler$ - ^ 20:51:01.354 [ERROR] i.g.a.ZincCompiler$ - one error found Compilation failed –
Well, at line 30 in your simulation there’s no single mention of headers .
Is this absolutely all the code of your CPC.scala file ? Looks like it’s not.
Could be wrong but I think it is complaining about .headers(sentHeaders)
I think .acceptHeader() is what you should be using but I could be wrong :S