Ok so I am reading To optimise performance and ensure that your application is interacting with the Betfair API as efficiently as possible, we strongly recommend the following as best practice and enable HTTP compression which I assume is adding
request.Headers.Add("Accept-Encoding", "gzip, deflate")
OK but where? I am using the CSharp example (ported to VB NET) and I have JsonRpcClient.vb which contains all the code to talk to API. Should I add this code into my constructor as follows
OR in CreateWebRequest function
I added both and tested but I get response errors so something wrong.
request.Headers.Add("Accept-Encoding", "gzip, deflate")
OK but where? I am using the CSharp example (ported to VB NET) and I have JsonRpcClient.vb which contains all the code to talk to API. Should I add this code into my constructor as follows
Public Sub New(ByVal endPoint As String, ByVal appKey As String, ByVal sessionToken As String)
'THIS CONSTRUCTOR ADDS THE URL AND THEN ADDS THE APPLICATION KEY AND SESSION TOKEN INTO OUR WEBREQUEST
Me.EndPoint = endPoint '& "/json-rpc/v1"
CustomHeaders = New NameValueCollection()
If appKey IsNot Nothing Then
CustomHeaders(APPKEY_HEADER) = appKey
'ADDED 13 MARCH 2017 AND HOPEFULLY SHOULD MAKE THE SYSTEM QUICKER?
'CustomHeaders("Accept-Encoding") = "gzip, deflate"
End If
If sessionToken IsNot Nothing Then
CustomHeaders(SESSION_TOKEN_HEADER) = sessionToken
End If
Me.Timeout = 10000
End Sub
'THIS CONSTRUCTOR ADDS THE URL AND THEN ADDS THE APPLICATION KEY AND SESSION TOKEN INTO OUR WEBREQUEST
Me.EndPoint = endPoint '& "/json-rpc/v1"
CustomHeaders = New NameValueCollection()
If appKey IsNot Nothing Then
CustomHeaders(APPKEY_HEADER) = appKey
'ADDED 13 MARCH 2017 AND HOPEFULLY SHOULD MAKE THE SYSTEM QUICKER?
'CustomHeaders("Accept-Encoding") = "gzip, deflate"
End If
If sessionToken IsNot Nothing Then
CustomHeaders(SESSION_TOKEN_HEADER) = sessionToken
End If
Me.Timeout = 10000
End Sub
'################################################# ################################################## ###############
'### CREATE WEB REQUEST ###
'################################################# ################################################## ###############
Protected Function CreateWebRequest(ByVal uri As Uri) As WebRequest
Dim request As WebRequest = WebRequest.Create(New Uri(EndPoint))
request.Method = "POST"
request.ContentType = "application/json-rpc"
request.Headers.Add(HttpRequestHeader.AcceptCharse t, "ISO-8859-1,utf-8")
ServicePointManager.Expect100Continue = False
'ADDED 13 MARCH 2017 AND HOPEFULLY SHOULD MAKE THE SYSTEM QUICKER?
'request.Headers.Add("Accept-Encoding", "gzip, deflate")
request.Headers.Add(CustomHeaders)
Return request
End Function
'### CREATE WEB REQUEST ###
'################################################# ################################################## ###############
Protected Function CreateWebRequest(ByVal uri As Uri) As WebRequest
Dim request As WebRequest = WebRequest.Create(New Uri(EndPoint))
request.Method = "POST"
request.ContentType = "application/json-rpc"
request.Headers.Add(HttpRequestHeader.AcceptCharse t, "ISO-8859-1,utf-8")
ServicePointManager.Expect100Continue = False
'ADDED 13 MARCH 2017 AND HOPEFULLY SHOULD MAKE THE SYSTEM QUICKER?
'request.Headers.Add("Accept-Encoding", "gzip, deflate")
request.Headers.Add(CustomHeaders)
Return request
End Function
I added both and tested but I get response errors so something wrong.


Comment