|
If anyone has had experience in writing and HTTP server I could use your advice.
I have been pulled into a project which involves modifyng existing HTTP server code to make the file down load work correctly. Where can I find the full spec on this. At present, unless the complete file is assembled in a buffer the server hangs. In the embedded environment we have serious memory constraints and can not prepare the data as a single large file and must send it in bits. The client end must however think it's a single file.
Any ideas on the structure of each packet would be welcome.
Happy programming!!
|
|
|
|
|
You're giving very little context to allow for an useful answer, but anyway...
The client should cope with the whole file as long as the server returns the contents of the file as the response to the HTTP request (i.e, thru the socket created in response to the HTTP request). It is not a matter of wheter you send it in chunks or all at once, what you have to investigate is the means of having the little chunks sent thru the same response socket. If this is already clear to you, then I guess little more can be said without knowing more about your environment.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm sorry, at this stage I don't much more about it myself. The source code is still on it's way (long story to do with international projects), but what I can work out is that when this server is sending out the chunks it omits something important in the chunk's header. That is why I'm trying to find a spec that will tell what the header in each chunk must have. Perhaps it's even the header of the first chunk is missing vital information.
I'm once I see the specification it won't be too hard to fix.
Happy programming!!
|
|
|
|
|
The HTTP spec is RFC 2616. Chunked transfers are described in section 3.6.1:
3.6.1 Chunked Transfer Coding
The chunked encoding modifies the body of a message in order to
transfer it as a series of chunks, each with its own size indicator,
followed by an OPTIONAL trailer containing entity-header fields. This
allows dynamically produced content to be transferred along with the
information necessary for the recipient to verify that it has
received the full message.
Chunked-Body = *chunk
last-chunk
trailer
CRLF
chunk = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*("0") [ chunk-extension ] CRLF
chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size(OCTET)
trailer = *(entity-header CRLF)
The chunk-size field is a string of hex digits indicating the size of
the chunk. The chunked encoding is ended by any chunk whose size is
zero, followed by the trailer, which is terminated by an empty line.
The trailer allows the sender to include additional HTTP header
fields at the end of the message. The Trailer header field can be
used to indicate which header fields are included in a trailer (see
section 14.40).
|
|
|
|
|
Thank you heaps
THis is what I am looking for. I have found that not all of this is being put into the 'chunk' by the present server code.
Happy programming!!
|
|
|
|
|
|
Last month I posted a problem about my dialog buttons not responsive. Thanks to reply posted by Christian, that's solved by using a worker thread.
I'm now having a couple of problems after solving the above. Hope someone can advise.
The worker thread is started when the user clicks on the CONVERT button. I then change the Cancel to be the default button, so that a simple Enter
would abort the very lengthy conversion.
void CConvert::OnConvert()
{
// start the worker thread
AfxBeginThread(MyThreadProc,this);
// change the buttons
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(FALSE);
m_ok.EnableWindow(FALSE);
m_cancel.SetButtonStyle(BS_DEFPUSHBUTTON);
m_cancel.SetFocus();
}
// my worker thread
UINT MyThreadProc (LPVOID pParam)
{
CConvert * pObject = (CConvert*)pParam;
pObject->DoConvert();
return 0;
}
// my original code to do all the conversion
BOOL CConvert::DoConvert(void)
{
// lots of code up here not shown
//
if (AbortFlag)
{
// conversion was cancelled. Dialog box is gone.
return FALSE;
}
else
{ // normal completion. Dialog box still visible.
// make the OK button default
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(TRUE);
m_cancel.SetButtonStyle(BS_PUSHBUTTON);
m_ok.SetButtonStyle(BS_DEFPUSHBUTTON);
m_ok.EnableWindow(TRUE);
m_ok.SetFocus();
// UpdateData(FALSE); // Cause Assertion Fail. Why?
}
return TRUE;
}
1/ After sucessful conversion the OK button is shown as the Default button, but when I hit Enter, conversion starts again. Seems like the focus is still on the Convert button. How come?
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
3/ I think I'm wrong to put all these button manipulations in the worker thread. Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread and then do these manipulations after the thread is done. Your advise please.
|
|
|
|
|
Hello, the codegurus around the world.;)
I have the same experience about UpdateData (FALSE).
Even though I didn't do this, try to use SendMessage (or PostMessage)
to update Button stuffs by the user defined message.
I think that Timer is the good option.
BTW, why do you use UpdateData (FALSE)?
UpdateData(FALSE) updates the string by the memeber value in the class wizard
because you only use the control value in the class wizard.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
et wrote:
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
Because MFC's design contains a map between HWNDs and CWnd objects. When you do any non-trivial operation on a window, MFC looks up the corresponding CWnd object in its map. However, each thread has its own map. Since the dialog was created by the main thread, the dialog is in the main thread's map. The worker thread can't find it in its map and asserts. (The previous calls work fine because it is safe to send messages between threads, which is what the calls boil down to.)
et wrote:
3/Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread
That's not the best way. Define a custom window message (WM_APP will do) and send that from the worker thread to the main thread right before the worker thread exits. Do your UI updating in response to that message.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi All!
I made a dialog application. When I build it using the appWizard, I did not choose to have menu on the dialog. Now I need to have a menu, can I add it in?
Thanks in advance
Vu
vucsuf
|
|
|
|
|
Yes, just assign a menu to the dialog using the resource editor.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I am creating a 'server' that will talk TCP/IP to other devices. This server will need to be multithreaded. So questions. Does Winsock2 support threads? Some functions like WSAWaitForMultipleEvents and WSACreateEvent seems to 'be' threaded. Are there any examples of creating a socket server? Also interested in outright buying the sources for a professionaly built one.
Thanks
Ralph Krausse
|
|
|
|
|
|
Hello,
I am having difficulties dynamically creating a CScrollBar object in a CView derived class.
It seems to have a problem attaching to the window during the CScrollBar.Create() method.
The odd thing, all works fine in a dialog or CFormView class. I am quite stumped!
If anyone can shed some light on my problem, I would be very greatfull!
Thanks,
James
|
|
|
|
|
MSVC 6.0 SP4 Windows 98 second edition
On an application I am working on, the buttons on one property sheet dialog are disappearing intermittantly.
Cancel, Apply and OK are like disappearing, for no apparent reason. If you click the spot where they
would be, the BN_CLICKED message does infact work, and IDOK/IDCANCEL are sent, also
DoDataExchange works too.
WTHeck,
Asher
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
chk whether the buttons r set to OWNER DRAW or chk for other properties.
Ganesh Ramaswamy
|
|
|
|
|
Well,
the buttons are:
OK,APPLY and CANCEL...default properties.
ahoodin;)
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
then i am sorry. i dont have VC++ compiler now to test. it will take a week for me to get. so all the best and i am sorry
Ganesh Ramaswamy
|
|
|
|
|
No need to apologize,
you didnt do a thing wrong.
ahoodin
thxe09!
Real generosity towards the future lies in giving all to the present.
-- Albert Camus
|
|
|
|
|
Sounds like a resource leak or something weird happening with your Windows 98. Does this happen immediately? Have you tested with Windows NT/2000?
Regards,
Alvaro
|
|
|
|
|
Well,
The application hasn't been tested on a Windows 2000/NT platform... Primarily because the drivers have all been written in vxd format for the hardware. I did however fire it up in Windows 2000 for a kick after you sent the note. The MFC portions of the application appear to work. The application needs an additional redraw occasionally.
The Application skips through all hardware intializations as expected.
The buttons that were problematic dissappeared on the 98 box over a period of a few weeks of constant running.
BTSOOM,
ahoodin
He that breaks a thing to find out what it is has left the path of wisdom.
-- Gandalf, The Lord of the Rings
|
|
|
|
|
In the application I am working on, I am having an interesting problem.
When I enter the dialog, the first radio button in the tab order is
automatically checked. One of the screens has 3 radio buttons, and only 3. They are not grouped, nor do they have the tab order hint set. The dialog is a popup style modeless dialog.
BOOL man2::OnInitDialog()
{ CDialog::OnInitDialog();
CRect r2; //the button is not set!!!
main_dlg->GetDlgItem(IDC_GENERAL)->GetWindowRect(&r2);// get size IDC_GENERAL
// Set prog window right on top of IDC_GENERAL area of screen, and show it
SetParent( main_dlg->GetDlgItem(IDC_GENERAL)); // IDC_GENERAL set 2 parent window
//the button is set, for some unknow reason the first push button in the
// tab order has been activated!!!
SetWindowPos( &main_dlg->wndTop,0,0,r2.Width(), r2.Height(), SWP_SHOWWINDOW);
return TRUE; // return TRUE unless you set the focus to a control
}
This does not cause any problems if the first tab order item is a static
text box rather then a control. Currently I fix this problem in this way, however
I am looking for answers on this one. I am not happy with this Hack. I don't think
the answer is as easy as tab order or group setting. It is not the default behavior of the
radiobutton.
ahoodin
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
I want to make a internet connection checker app that disconnect the connection if it has past i.e 1 hour. My problem is: How to disconnect?
I know how to use the RasHangUp(..) but how can I disconnect when I don't have connected using RasDial(..)?
HELP!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I don't know about RAS. However when using a modem dialup to the internet. I usually use TAPI with the lineDrop method to drop a call. Of course you need to have opened the device through TAPI first.
Michael
|
|
|
|
|
I'm working on a DLL that initially did not have MFC support, and it also uses the WINAPI ENTRYPOINT construct for allowing access to it's functionality.
I changed the project settings to support MFC, and I know how to add a dialog box, but it doesn't come up like a normal app does. Instead, it saves it in a (resource?) "script". Further, ClassWizard is not available, even after the dialog resource is created in the project.
Can I just cut and paste MFC dialog box code into the class I create?
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|