rejetto forum

Macros to serve HTTP status codes

raybob · 25 · 10168

0 Members and 1 Guest are viewing this topic.

Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Can you create a macro command to directly serve different HTTP codes to the user, for example something like {.if| I want to give this user a deny-403 code |{:{.serve|403.}:}.}

Reason I ask is because in certain cases I want to direct a user to the deny page but using {.redirect|/~deny.} will confuse search engines and browsers into thinking that the page exists and is accessible but got temporarily moved....  This would also be useful for serving a 307 code since using {.redirect.} only constitutes a temporary redirect, not a permanent one.

Thanks!
« Last Edit: August 20, 2011, 03:46:01 AM by raybob95 »


Offline FRENCH CAN CAN

  • Tireless poster
  • ****
    • Posts: 681
    • View Profile
At the head section of your template:

<meta name="robots" content="noindex,nofollow,noarchive,nosnippet">

you should get the desired effect.


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
No, I'm looking for a way to actually use a macro to serve HTTP status codes of my choosing in the response headers; for users not just search engines, and for a variety of applications.
« Last Edit: August 20, 2011, 03:47:08 AM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Like {.if| I want to hide this page |{:{.http status|404.}:}.} or {.if| I want to deny this user |{:{.http status|403.}:}.}  or  {.if| I permanently moved this file |{:{.http status|301.}{.add header|Location: http://website.tld/.}:}.}

Something to that effect would be very useful.

This can very easily be done in PHP...  <?php header("HTTP/1.1 404 Not Found"); ?>
« Last Edit: September 02, 2011, 04:36:17 PM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
yes i mean to add something like that.
that was already in the to-do list, in this line

+ macros missing to cache a folder: {.reply|content=|var=|code=|filename=|mime=.}


i meant it as a way to provide cached content, but it would work for your purpose too.
keep an eye on future builds for new commands.
unfortunately i didn't solve my problems stopping me from developing hfs yet. :(


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Rather than creating a new topic, I'll just ask here....

Have you ever thought about creating a command that functions similar to javascript setTimeout() or PHP sleep()
« Last Edit: September 19, 2011, 02:12:07 AM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
mmm, nope.
But sleep is out of question because HFS is not multi-threaded.
Would you need a setTimeout ?


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
But sleep is out of question because HFS is not multi-threaded.

Is that something you plan on doing in the future is making HFS multithreaded?  Perhaps one thread per connection would be effective :)

HFS frequently maxes out my CPU on its allotted core (and this is a Core i7 here) and then the GUI freezes up....

Generally if I have >8 active downloads HFS lags to the point that it's basically knocked offline because I can't even access it from within my LAN in under a minute.  That's on a VM server with an i7 and 3GB RAM.

EDIT:

Also I ask about setTimeout or something like that because capturing the output of a batch file only works if the batch takes under a certain amount of time to complete, like HFS doesn't wait for it.
« Last Edit: October 17, 2011, 01:00:18 AM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
Is that something you plan on doing in the future is making HFS multithreaded?

that won't come until a full rewrite of HFS.
would i have the time, i would go for a multiplatform version based on Python.

Quote
Generally if I have >8 active downloads HFS lags to the point that it's basically knocked offline because I can't even access it from within my LAN in under a minute.  That's on a VM server with an i7 and 3GB RAM.

wow. What's the total upload speed at that moment?

Quote
Also I ask about setTimeout or something like that because capturing the output of a batch file only works if the batch takes under a certain amount of time to complete, like HFS doesn't wait for it.

but you don't know how long will the batch take, right?
you may wait too long, or arrive too early.
it's better if the "fetcher" of the result is in a timed event, isn't it?



Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
wow. What's the total upload speed at that moment?

My internet doesn't go above 120KB/s (which is slightly problematic).  HFS doesn't lag based on total upload speed but rather number of concurrent connections.  I can easily get over 8MB/s with no lag on my local LAN if no one else is connected.

That being said there is a total of ~200 macros that get executed under [request] according to the macro-log and 542 items in my VFS   ;D

Do you think the fact that it's under a VM has much effect?  Every other application seems to run the same speed...

BTW what I said before wasn't totally accurate.... here's what I measured: >4 downloads makes the GUI slower, >10 downloads makes the GUI unusable by taking >10 seconds to show anything, >12 downloads makes a page take longer than 10 seconds to load and >15-20 downloads will make Firefox time out when loading a page.  HFS has only been knocked offline once for me (completely unresponsive in GUI and over HTTP) and it had around 30 (concurrent) downloads.

I also tried disabling browsing compression but it didn't seem to have an effect.
« Last Edit: October 31, 2011, 12:58:21 AM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
your [request] script is executed only at the beginning of the connection.
in case the gui is slow also when no connections are established, it must be something else.
a quick test could be done by disabling your scripts for a while: you can just rename the hfs.events file


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com

Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Disabling events actually didn't seem to have an effect.

Today during some heavy traffic I tried temporarily disabling options and I managed to hit a record of 8 HTTP requests/second (something like 1000 HTTP packets per second) with literally zero lag.  It was pretty cool  :D  Restoring the options pretty much immediately locked up the interface.

The following things I tried all had no effect:

Disabling Apache Log
Disabling Compressed Browsing
Disabling preventing download accelerators
clearing ban list
turning off high speed handling
« Last Edit: November 11, 2011, 05:37:38 PM by raybob »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i didn't understand, what's the result you just told, was it something different? and how did you get it?