Author Topic: HFS returning OK (200) to POST even when upload fails  (Read 1070 times)

0 Members and 1 Guest are viewing this topic.

Offline dr_st

  • Occasional poster
  • *
  • Posts: 1
    • View Profile
HFS returning OK (200) to POST even when upload fails
« on: November 23, 2017, 08:36:41 AM »
Hi all,

I am a new user and found HFS when I was looking for a simple, light-weight HTTP server that I could test upload flows from my client.

Generally it worked well for me, and the server is a joy to configure and use. Great job! 8)

I noticed one thing that seemed strange to me. If I try to upload a file (using POST) without a proper permission configured, the file does not get uploaded, and the server reports "upload failed: not allowed". However, it still returns an OK (200) response to the client. Is that normal? If that's expected behavior from the server side, what should the client do to determine that the upload actually failed?

I am new to HTTP, so I wasn't sure whether it's a bug or normal behavior. That's why I opened it in the general forum.

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 788
  • I'm only trying to help i mean no offense.
    • View Profile
    • none - google translate
Re: HFS returning OK (200) to POST even when upload fails
« Reply #1 on: January 13, 2018, 04:08:14 AM »
you will probaly have to add a html code macro to give you soem more info:

https://stackoverflow.com/questions/32901015/how-to-add-header-authorization-for-post-form-using-js-ajax-jquery

some thing like this as seen form link above...
-------------------------

Html form code :

         
Code: [Select]
  <form><!---Removed form submit url-->
            <input type="text" id="keyName" value="testValue">
            <!---Id attribute added to input field to be submitted--->
            <input type="button" onclick="myFunction()" value="Submit">
            <!---Input type is button NOT submit--->
            </form>

Javascript code:

Code: [Select]
function myFunction(){
var dataValue = $("#keyName").val();
$.ajax({
            type : 'POST',
            //remove the .php from results.php.php
            url : "http://externalsite.cpm/results.php",
            //Add the request header
            headers : {
                Authorization : 'Bearer ' + 'XXXXXXXXXXXXXXXXXXXXXXXXX'
            },
            contentType : 'application/x-www-form-urlencoded',
            //Add form data
            data : {keyName : dataValue},
            success : function(response) {
                console.log(response);
            },
            error : function(xhr, status, error) {
                var err = eval("(" + xhr.responseText + ")");
                console.log(err);                   
            }
        }); //End of Ajax
}   // End of myFucntion


---------------------

more info aon addind data to the header:
...

http://www.rejetto.com/forum/hfs-~-http-file-server/posting-to-hfs-using-wfetch-tool-(http-post)-not-saving-file-to-folder/msg1060575/#msg1060575

BUT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

REJETO has already answered this on a previous form post:

Re: Posting to HFS using Wfetch tool (HTTP Post) not saving file to folder
« Reply #9 on: August 31, 2015, 09:51:08 AM »
POST is generic. HFS needs data to be sent as "multipart", in the POST. That's what the browser does.
See if you have such option on your side.
« Last Edit: August 31, 2015, 09:59:15 AM by rejetto »

http://www.rejetto.com/forum/hfs-~-http-file-server/changing-http-response-header/
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1