aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: [1] 2

Author Topic: Minors webserver improvements  (Read 6630 times)

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Minors webserver improvements
« on: November 11, 2006, 04:12:01 PM »

Hi,
I don't succed to clearly understand this really big src/webserver/src/WebServer.cpp file. So i suggest here.
I'm making a webserver interface with AJAX and i think that some minors change can help developpement:

-recognise .css, .js (it seems that there are something about it in WebSever.cpp but it doesn't work)
-recognise "?something" in image file url, and discard it.
-debug include (NOT MINOR, .lex seems ok but it doesn't work)

The first would allow proper developpement (.js instead of .js.html)

The second would allow to generate different urls for the same file in order to refresh cache for progress image (dyn_***HASH***.png). For exemple with javascript create a "dyn***HASH***.png?random_number".

Regards,
« Last Edit: November 11, 2006, 04:25:07 PM by Ju1i3n »
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
RE: Minors webserver improvements
« Reply #1 on: November 11, 2006, 04:46:30 PM »

I found the solution...

edit: delete incomplete code
« Last Edit: November 11, 2006, 10:51:29 PM by Ju1i3n »
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
RE: Minors webserver improvements
« Reply #2 on: November 11, 2006, 10:47:31 PM »

Here is a working patch

diff -r aMule-2.1.3/src/webserver/src/WebServer.cpp aMule-2.1.3-patchws/src/webserver/src/WebServer.cpp
197c197,199
<               m_file = url.AfterFirst('/');
---
>               m_file = url.BeforeFirst('?').AfterFirst('/');
>       } else {
>               m_file = url;
304c306
<       wxString imgName = wxFileName::GetPathSeparator() + wxFileName(Data.sURL).GetFullName();
---
>       wxString imgName = wxFileName::GetPathSeparator() + wxFileName(Data.sURL.BeforeFirst('?')).GetFullName();
1890c1892
<       if ( req_file.Find(wxT(".html")) != -1 ) {
---
>       if ( req_file.Find(wxT(".html")) != -1 || req_file.Find(wxT(".css")) != -1 || req_file.Find(wxT(".js")) != -1) {
diff -r aMule-2.1.3/src/webserver/src/WebSocket.cpp aMule-2.1.3-patchws/src/webserver/src/WebSocket.cpp
340,341c340,342
<       if (sURL.Length() > 4 ) {
<               wxString url_ext = sURL.Right( sURL.Length() - sURL.Find('.', true) ).MakeLower();
---
>       wxString sFile = Data.parsedURL.File();
>       if (sFile.Length() > 4 ) {
>               wxString url_ext = sFile.Right( sFile.Length() - sFile.Find('.', true) ).MakeLower();
« Last Edit: November 11, 2006, 10:50:05 PM by Ju1i3n »
Logged

lfroen

  • Guest
Re: Minors webserver improvements
« Reply #3 on: November 12, 2006, 02:40:05 PM »

Sorry,  but your patch is not really "working". First of all, it must be unified, i.e. created with -u option. Second, only patches against current SVN snapshots have any sense. And third - it should be attached, not pasted.
Now to the matter of thing. Can you please explain the problem (except of not recognizing .js and .css)?
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Re: Minors webserver improvements
« Reply #4 on: November 13, 2006, 03:03:34 PM »

OK. I try to update to current svn version but, it seems to be broken.
(amule: ./libs/ec/ECTag.h:164: std::string CECTag::GetStringDataSTL() const:  assertion « (m_dataType == EC_TAGTYPE_STRING) || (m_dataType == EC_TAGTYPE_UNKNOWN) »  failed)

The first problem is '?something' in image url.
- In WebSocket.cpp, the file extension is dermined from sURL instead of filename (present in class CParsedUrl in Threaddata). So if there's "file.ext?useless" ext were "less" instead of "ext".
- Same problem in WebServer.cpp in ProcessImgFileReq.

Secondly, in CParsedUrl (WebServer.cpp) constructor the result seems strange if sURL doesn't start with '/'.

The third change is to recognise .css and .js file. The send process is exactly the same than html data that why ProcessHtml(data) could be used. Only content-type field differs.

Here is an UNTESTED patch for current svn (i only know that it compiles). It might have bug. Current svn version is broken, and my linux workstation (sparc ultra5) is definitly too slow to compile svn version until finding a working one.
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Minors webserver improvements
« Reply #5 on: November 13, 2006, 07:49:57 PM »

Current svn version is not broken.
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Re: Minors webserver improvements
« Reply #6 on: November 14, 2006, 10:55:22 AM »

Quote
Originally posted by Kry
Current svn version is not broken.
aMule-CVS-20061113.tar.bz2 ?

I'll try again with aMule-CVS-20061114.tar.bz2
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Re: Minors webserver improvements
« Reply #7 on: November 14, 2006, 03:13:37 PM »

aMule-CVS-20061114.tar.bz2 is not working with my configuration on my workstation:
$bin/amule  --i-would-marry-my-mule
Initialising aMule
Checking if there is an instance already running...
No other instances are running.
Loading temp files from /home/ju1i3n/Temp.
HTTP download thread started

All PartFiles Loaded.
ListenSocket: Ok.

*** TCP socket (ECServer) listening on 0.0.0.0:4712
*** Server UDP socket (TCP+3) at 0.0.0.0:15665
*** TCP socket (TCP) listening on 0.0.0.0:15662
*** Client UDP socket (extended eMule) at 0.0.0.0:15672
HTTP download thread ended
amule: ./libs/ec/ECTag.h:164: std::string CECTag::GetStringDataSTL() const:  l'assertion « (m_dataType == EC_TAGTYPE_STRING) || (m_dataType == EC_TAGTYPE_UNKNOWN) » a échoué.
Abandon

(gdb) bt
#0  0x7096eee8 in kill () from /lib/libc.so.6
#1  0x70048dd0 in pthread_kill () from /lib/libpthread.so.0
#2  0x700491e4 in raise () from /lib/libpthread.so.0
#3  0x7096eb0c in raise () from /lib/libc.so.6
#4  0x70970450 in abort () from /lib/libc.so.6
#5  0x70966fd0 in __assert_fail () from /lib/libc.so.6
#6  0x0011cbb0 in CECTag::GetStringDataSTL (this=0xc262d0) at ./libs/ec/ECTag.h:164
#7  0x0011ca8c in CECTag::GetStringData (this=0xc262d0) at ./libs/ec/ECTag.h:170
#8  0x00112464 in ExternalConn::Authenticate (request=0xbae088) at ExternalConn.cpp:193
#9  0x00110e5c in CECServerSocket::OnPacketReceived (this=0xc595a8, packet=0xbae088)
    at ExternalConn.cpp:78
#10 0x004162e0 in CECSocket::OnInput (this=0xc595a8) at ECSocket.cpp:399
#11 0x004144cc in CECSocketHandler::SocketHandler (this=0x82bff8, event=@0xc5ccd8) at ECSocket.cpp:192
#12 0x706525b8 in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#13 0x707149f8 in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.6.so.0
#14 0x70714d70 in wxEventHashTable::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#15 0x70715ad0 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#16 0x70715838 in wxEvtHandler::ProcessPendingEvents () from /usr/lib/libwx_baseu-2.6.so.0
#17 0x70652504 in wxAppConsole::ProcessPendingEvents () from /usr/lib/libwx_baseu-2.6.so.0
#18 0x70352f28 in wxPaletteBase::GetColoursCount () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#19 0x70ff31b8 in g_child_watch_add () from /usr/lib/libglib-2.0.so.0
#20 0x70ff31b8 in g_child_watch_add () from /usr/lib/libglib-2.0.so.0

edit: add backtrack
« Last Edit: November 14, 2006, 04:22:15 PM by Ju1i3n »
Logged

lfroen

  • Guest
Re: Minors webserver improvements
« Reply #8 on: November 17, 2006, 08:57:50 AM »

I mostly applied your fixes, except of this one:

Code: [Select]
diff -u amule-cvs/src/webserver/src/WebServer.cpp amule-cvs-patchws/src/webserver/src/WebServer.cpp
--- amule-cvs/src/webserver/src/WebServer.cpp 2006-07-23 21:13:58.000000000 +0200
+++ amule-cvs-patchws/src/webserver/src/WebServer.cpp 2006-11-13 14:27:27.000000000 +0100
@@ -176,6 +176,8 @@
  if ( url.Find('/') != -1 ) {
  m_path = url.BeforeFirst('/');
  m_file = url.AfterFirst('/');
+ } else {
+ m_file = url;
  }

Can you explain when it makes difference ?
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: Minors webserver improvements
« Reply #9 on: November 17, 2006, 12:02:28 PM »

Quote
Originally posted by Ju1i3n
Quote
Originally posted by Kry
Current svn version is not broken.
aMule-CVS-20061113.tar.bz2 ?

I'll try again with aMule-CVS-20061114.tar.bz2
aMule CVS code can be broken, yes. :P
See that: (src/libs/ec/ECTag.h)
Code: [Select]
   168                 #ifdef USE_WX_EXTENSIONS
    169                 wxString GetStringData(void) const {
    170                         return UTF82unicode(GetStringDataSTL().c_str());
    171                 }
    172                 #endif
Ju1i3n probably has wx compiled with STL strings. So, he, who has written this EC code, please, test it again. But use a wx where USE_WX_EXTENSIONS is defined.

Ju1i3n, thank you for your backtrace, it really helped.

Please try to disable EC to see if aMule works. If disabling EC is an option, you can use it like that until we fix it.

Cheers!
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Minors webserver improvements
« Reply #10 on: November 17, 2006, 12:07:07 PM »

How is that related or make any sense, phoenix?
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: Minors webserver improvements
« Reply #11 on: November 17, 2006, 12:15:08 PM »

Some more lines then:

Quote
amule: ./libs/ec/ECTag.h:164: std::string CECTag::GetStringDataSTL() const: l'assertion « (m_dataType == EC_TAGTYPE_STRING) || (m_dataType == EC_TAGTYPE_UNKNOWN) » a échoué.
Abandon

Code: [Select]
   163                 std::string     GetStringDataSTL(void) const {
    164                         assert((m_dataType == EC_TAGTYPE_STRING) || (m_dataType == EC_TAGTYPE_UNKNOWN));
    165                         return ((char*)m_tagData);
    166                 }
    167
    168                 #ifdef USE_WX_EXTENSIONS
    169                 wxString GetStringData(void) const {
    170                         return UTF82unicode(GetStringDataSTL().c_str());
    171                 }
    172                 #endif
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: Minors webserver improvements
« Reply #12 on: November 17, 2006, 12:29:41 PM »

Ju1i3n,

Could you use gdb and give us some state?

Maybe

frame 6
p m_dataType

Are you sure you are using the EC client and the EC server from the same CVS tarball?

Cheers!
Logged

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Re: Minors webserver improvements
« Reply #13 on: November 20, 2006, 08:20:17 PM »

Quote
Originally posted by phoenix
Are you sure you are using the EC client and the EC server from the same CVS tarball?/quote]

Arg! Stupid!

I wanted to go too fast and i didn't saw that amule automatically load the first amuleweb in path, that's why it crashed.
Maybe a warning message would be fine.

So i'm really sorry for this false bug.

@lfroen
Code: [Select]
diff -u amule-cvs/src/webserver/src/WebServer.cpp amule-cvs-patchws/src/webserver/src/WebServer.cpp
--- amule-cvs/src/webserver/src/WebServer.cpp 2006-07-23 21:13:58.000000000 +0200
+++ amule-cvs-patchws/src/webserver/src/WebServer.cpp 2006-11-13 14:27:27.000000000 +0100
@@ -176,6 +176,8 @@
  if ( url.Find('/') != -1 ) {
  m_path = url.BeforeFirst('/');
  m_file = url.AfterFirst('/');
+ } else {
+ m_file = url;
  }
Is it possible for an URI not to start with / ?

I've just tested my patch on cvs version. It seems to work fine.

Here you can find a preview (only transfert and search tabs) of my ajax version of webserver frontend.
Code needs some cleaning but it works fine on IE7 and FF.
« Last Edit: November 20, 2006, 08:22:01 PM by Ju1i3n »
Logged

Vollstrecker

  • Administrator
  • Hero Member
  • *****
  • Karma: 67
  • Offline Offline
  • Posts: 1549
  • Unofficial Debian Packager
    • http://vollstreckernet.de
Re: Minors webserver improvements
« Reply #14 on: November 20, 2006, 11:34:43 PM »

Quote
Originally posted by Ju1i3n

Is it possible for an URI not to start with / ?


You mean like http://? Or is thos stripped before?
Logged
Homefucking is killing prostitution
Pages: [1] 2