Streaming byte array (wodHttpDLX)
I need to send data as a Unicode UTF8 stream. Is this possible? What would the code look like?
Thanks
by AtlantaGator, (2807 days ago)
I need to send data as a Unicode UTF8 stream. Is this possible? What would the code look like?
Thanks
by Jasmine, (2806 days ago) @ AtlantaGator
Hi.
I don't think you can stream data with wodHttpDLX, since it is based on fixed-length request and responses.
I assume you want to broadcast video using the component? I don't think it can be used in that way.
Kind regards,
Jasmine.
by AtlantaGator, (2806 days ago) @ Jasmine
Jasmine,
Thanks for the reply.
What I meant by streaming is how data is sent through code.
I need to send a byte array to an api for credit card processing.
The data must be encoded (UTF8).
I am sending CC data plus the log in info.
I am unable to connect with the server.
I am able to connect using C# or VB.Net code without the HttpDLX object - using straight code.
BTW - I am using HttpDLX with VBA.
Thanks
by Jasmine, (2806 days ago) @ AtlantaGator
Hi.
Can you paste your C# code with dummy data, so I can see how it looks like, and try to translate it to wodHttpDLX?
Jasmine.
by AtlantaGator, (2806 days ago) @ Jasmine
Jasmine,
Thanks for your assistance.
Here is my code:
string mytran = "Login Credentials and CC Data";
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("webaddress");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
byte[] byteArray = Encoding.UTF8.GetBytes(mytran);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
Stream dataStream;
try
{
// Get the request stream.
dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
}
catch (Exception f)
{
MessageBox.Show(f.ToString());
}
// Get the response.
WebResponse response = request.GetResponse();
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
by Jasmine, (2806 days ago) @ AtlantaGator
Hi.
This should be pretty much straightforward, there's no stream of data, you can fill Request.Body with contents of stream. I assume stream isn't too large (in terms of megabytes) anyway.
So, something like this should do
Http1.Request.Headers.Add("Content-type: application/x-www-form-urlencoded")
Http1.Request.Body = "...put everything from the stream here"..
Http1.Post(URL)...
I think you don't need anything else. By default wodHttpDLX uses UTF8, but you can also specify it in Http1.Request.Charset if you wish, or you can write directly to Http1.Request.Filename (since Body actually internally reads/writes to it).
Can you try above?
Jasmine.
by AtlantaGator, (2806 days ago) @ Jasmine
Jasmine,
I get the same response as before: I don't have permission to access the server.
Since the server credentials are in the body, my assumption is that the server cannot read the body properly, like it can from C#.
I tried with 2 body arguments:
in one case I encoded the string, the other I did not - I sent the string unaltered
Could it be that I am using VBA and not VB?
Thanks
by Jasmine, (2806 days ago) @ AtlantaGator
Hi
VBA/VB cannot make a difference. Server don't know what you're using. Simply - data you are sending isn't same in both cases.
If you can somehow capture what you're sending in C# (such as with Fiddler) and then capture what you're sending with wodHttpDLX (with same Fiddler) you can spot the difference - and then just make the change in wodHttpDLX. It's usually just adding one header, changing body a bit or something simple.
Jasmine.
by AtlantaGator, (2806 days ago) @ Jasmine
Jasmine,
Excellent idea - I will be back - thanks.
by AtlantaGator, (2806 days ago) @ AtlantaGator
Jasmine,
What kind of data does the Http1.Request.Body expect ?
Can it handle a byte array ?
Will it know that the argument is an array?
Thanks
by Jasmine, (2805 days ago) @ AtlantaGator
Hi
Request.Body is a string. So, you can convert byte array to it. However, it could be safer and easier to you to write to Request.Filename file directly, so there's no conversion needed, just dump byte array to it and wodHttpDLX will use it.
Jasmine.
Brilliant, even works on the mobile phone...
I really like these products - they are consistently first rate!
...wodFtpDlx was exactly what I needed, it worked, and it was priced right...
The people at WeOnlyDo are amazing! ... I always get a super fast response from customer service, and the products are great too. Thanks WeOnlyDo
...with a minimum of effort as the DLL interface was written with such simplicity...
...I'm extremely impressed with the product, it represents excellent value for money...
You made it so simple for us to integrate SFTP - a technology we had little experience with...
I would highly recommend this to anyone who needs a good quality SFTP solution.
...not only that you provide these components at very reasonable cost, your responsiveness to emailed technical questions is simply outstanding...
Congratulations on an excellent product and first rate support!