RTC Forums
November 24, 2024, 03:11:59 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
Lesson 4 - sending a large file that needs to be created first
Pages: [
1
]
« previous
next »
Print
Author
Topic: Lesson 4 - sending a large file that needs to be created first (Read 4290 times)
mthand
RTC Expired
Posts: 17
Lesson 4 - sending a large file that needs to be created first
«
on:
April 08, 2013, 10:05:29 PM »
I am working with lesson 4 regarding "Sending large files out" and it works great - with one small problem.
When the file is a test file that already exists, it's fine.
But now that I have that part working, what I really need is to create a file (based on the GET query parameters), then create an HTML file which I then want to send. That might take 4 or 5 seconds. But the CheckRequest at the point of the Accept immediately looks for the file, to set ContentLength, which in this case is -1.
So my question is what is the procedure to handle the CheckRequest and OnDataReceived when there will be a delay in order to first create the file I want to send ?
Thanks for any help. All in all I'm extremely happy with what i can accomplish with these tools.
-John
Logged
D.Tkalcec (RTC)
Administrator
Posts: 1881
Re: Lesson 4 - sending a large file that needs to be created first
«
Reply #1 on:
April 12, 2013, 01:35:02 PM »
If it is a
GET
request with no content body (all the parameters are inside the HTTP header), then you can create the file directly inside the On
CheckRequest
event before calling "
Accept
" and before calling Write or WriteHeader.
If it is a
POST
request, where you also need to process the request content body before you can create the file for your response, you should only call the "
Accept
" method from the On
CheckRequest
event, but you should NOT call Write nor WriteHeader from OnCheckRequest. You should then implement the On
DataReceived
event to receive the complete request content (for example, by using "if TRtcDataServer(Server).Request.Complete then ..."), read the content body, prepare the file you want to send, and start sending the file from the same On
DataReceived
event. To continue sending the file out, simply use the OnDataSent event as shown in the Server Lesson 4.
Best Regards,
Danijel Tkalcec
Logged
mthand
RTC Expired
Posts: 17
Re: Lesson 4 - sending a large file that needs to be created first
«
Reply #2 on:
April 14, 2013, 11:36:42 AM »
Ok, I understand. In my case I ended up delaying in the CheckRequest before the Accept, but I'll take a look at the other option too.
Thanks
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...