PxPlus User Forum

Twitter Twitter Twitter

Author Topic: ERROR 302 file not found  (Read 1286 times)

edjack

  • Silver Member
  • ***
  • Posts: 45
  • Computerease
    • View Profile
ERROR 302 file not found
« on: March 25, 2024, 01:50:26 PM »
I do the following [tcp] GET from a web site and get an error 302 (file not found)
Here is the code I am using:
08120  LET R$="GET /download/update/ HTTP/1.0"+$0D0A$
08130  LET R$+="Accept-Language: en-us"+$0D0A$
08140  LET R$+="Content-Type: application/x-www-form-urlencoded"+$0D0A$
08150  LET R$+="Host: www.website.ca"+$0D0A$
08160  LET R$+="Content-Length: "+STR(LEN(PARAMS$))+$0D0A$
08170  LET R$+="Cache-Control: no-cache"+$0D0A$+$0D0A$
08180  CLOSE (1);
       OPEN (1,ERR=*NEXT)"[tcp]www.website.ca;80";
       GOTO 8200
08190  MSGBOX "Unable to connect to the Upgrade Web Site.","Connection Failure","!,TIM=15";
       LET CMD_STR$="END";
       RETURN
08200  WRITE RECORD (1)R$;
       LET RESP$="",X$=""
08210  WHILE 1
08220  READ RECORD (1,TIM=1,ERR=*BREAK)X$
08230  LET RESP$+=X$
08240  WEND
08250  CLOSE (1)

It should bring back the contents of file "index.html" but reports that it cannot find the file.
If I enter the full path to the website and directory in my browser it do get the contents of the "index.html" file.

any ideas on what can be wrong?

Ed Jack
Computerease

Loren Doornek

  • Gold Member
  • ****
  • Posts: 85
    • View Profile
Re: ERROR 302 file not found
« Reply #1 on: March 25, 2024, 02:21:17 PM »
Does it work if you actually include the filename in the URL?

08120  LET R$="GET /download/update/index.html HTTP/1.0"+$0D0A$

edjack

  • Silver Member
  • ***
  • Posts: 45
  • Computerease
    • View Profile
Re: ERROR 302 file not found
« Reply #2 on: March 25, 2024, 03:40:51 PM »
Does it work if you actually include the filename in the URL?

it does not work if i use the file name.
Ed Jack
Computerease

Stéphane Devouard

  • Diamond Member
  • *****
  • Posts: 122
  • PxPlus guru with skills in PHP, JS, C#, Java
    • View Profile
    • Stéphane's Web Resume
Re: ERROR 302 file not found
« Reply #3 on: March 25, 2024, 04:24:12 PM »
Hi

HTTP error 302 is not a file not found error but a redirect status

You should use the *plus/web/request http client instead, which will follow redirections

Regards
« Last Edit: March 26, 2024, 11:14:26 AM by Stéphane Devouard »
Stéphane Devouard
Portfolio | Work

edjack

  • Silver Member
  • ***
  • Posts: 45
  • Computerease
    • View Profile
Re: ERROR 302 file not found
« Reply #4 on: April 05, 2024, 11:01:03 AM »
that worked... thanks.
Ed Jack
Computerease