EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Adding headers in PUT request (.net Application)

Posted: 12/07/2015 04:49:34
by Leo Lampidis (Basic support level)
Joined: 12/07/2015
Posts: 3

I'm developing a .net windows application that needs to communicate with a server to send Json data with PUT requests. When I'm trying to add headers to the request using the OnPreparedHeaders event and the SetRequestHeader() function I'm getting the following exception: Cannot inflate compressed data. (error code is 100357)
Could you please suggest me a solution to this issue?

My source code is the following:

Imports System.Text
Imports SBHTTPSClient
Imports SBStringList
Imports SBX509
Imports System.IO

Public Class MyRestClient

Private WithEvents httpsClient As TElHTTPSClient

Public Sub New()
SBUtils.Unit.SetLicenseKey("My key is here!")

httpsClient = New TElHTTPSClient()
httpsClient.RequestParameters.ContentType = "application/json"
End Sub

Private Function PerformRequest(url As String, jsonBody As String) As String
Dim receivedText As String = ""

Using ms As New MemoryStream
httpsClient.OutputStream = ms

httpsClient.Put(url, jsonBody)

receivedText = ASCIIEncoding.UTF8.GetString(ms.ToArray())
End Using

Return receivedText
End Function

Private Sub httpsClient_OnCertificateValidate(Sender As Object, X509Certificate As TElX509Certificate, ByRef Validate As Boolean) Handles httpsClient.OnCertificateValidate
Validate = True
End Sub

Private Sub httpsClient_OnPreparedHeaders(Sender As Object, Headers As TElStringList) Handles httpsClient.OnPreparedHeaders
httpsClient.SetRequestHeader("Header1", "Value1")
httpsClient.SetRequestHeader("Header2", "Value2")
End Sub

End Class
Posted: 12/07/2015 04:52:55
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

Please set httpsClient.UseCompression to 'false'. Our code is already improved to eliminate this issue in the future.

I’ve noticed there is no Support Access Ticket linked to your user account on EldoS site. Technical Support is provided to customers with the linked Support Access Ticket. You will find your Support Access Ticket together with all the details about how to use it in the registration e-mail that we’ve sent to you upon the purchase.

If you are evaluating the product and don't have a license yet, please let us know and then you can have support according to Basic support level. Basic support level includes answering basic technical questions that appear during product evaluation period. We also offer Premium support for a purchase from https://www.eldos.com/support/calc.php . You can use Premium Support to get higher level of assistance during your evaluation of our products.
Posted: 12/07/2015 06:20:50
by Leo Lampidis (Basic support level)
Joined: 12/07/2015
Posts: 3

Thank you very much for the quick response.

The solution you suggest me works fine but I fine another one issue.
The string that is sending to the server is corrupted with the code above. I'll have to convert the string to byte array and send the byte array.

httpsClient.Put(url, ASCIIEncoding.UTF8.GetBytes(jsonBody))

instead of
httpsClient.Put(url, jsonBody)
Posted: 12/07/2015 06:26:39
by Vsevolod Ievgiienko (Team)

According to the code the first method should convert a string to UTF8 internally. Could you please clarify how is the string corrupted.
Posted: 12/07/2015 08:12:45
by Leo Lampidis (Basic support level)
Joined: 12/07/2015
Posts: 3

I used the event OnSendData to get the data that I'm sending to the server. Then I compare the byte array (converted to UTF-8) from the event with the string I'm passing to Put function. The data provided by the event are containing one part of the data I'm passing to Put.
But when I call the Put with Byte array, instead of string, the data provided by the event contain the the whole data I'm passing to Put.
Posted: 12/07/2015 08:22:19
by Vsevolod Ievgiienko (Team)

OnSendData may be fired multiple times for a single request, so one call may report a part of the date being sent.



Topic viewed 2046 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!