mIRC Home    About    Download    Register    News    Help

Print Thread
HTTP Post Request #83642 21/05/04 08:09 AM
Joined: Jan 2003
Posts: 6
R
reino Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jan 2003
Posts: 6
Hi,

i wanna send a http post request

sockwrite -tn $sockname POST /jule/index.php HTTP/1.1
sockwrite -tn $sockname Host: %back_ip
sockwrite -tn $sockname Content-type: application/x-www-form-urlencoded
sockwrite -tn $sockname
sockwrite -tn $sockname data $+ = $+ $read(%back_filename,n,%i)
sockwrite -tn $sockname Connection: close
sockwrite -tn $sockname data $+ = $+ $read(%back_filename,n,%i)
sockwrite -tn $sockname

but it doesnt work correctly.. anyone knows how to sent the headers correct?


Re: HTTP Post Request #83643 21/05/04 11:43 AM
Joined: Dec 2003
Posts: 219
F
fxmakers Offline
Fjord artisan
Offline
Fjord artisan
F
Joined: Dec 2003
Posts: 219
Hi!

You're in the right way, but some headers are missing:
Optionnals (some httpd requires them) are the User-Agent, the Referer, the Accept-Language and the Accept header.
Required in a POST request is the Content-Length (missing in your script)
and maybe the Cookie if the server sent one.

Here's a classical POST request:

/set %data data $+ = $+ $read(%back_filename,n,%i)

sockwrite -tn $sockname POST /jule/index.php HTTP/1.1
sockwrite -tn $sockname Host: %back_ip
sockwrite -tn $sockname User-Agent: Mozilla/5.0
;optionnal: sockwrite -tn $sockname Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
;optionnal: sockwrite -tn $sockname Accept-Language: en-us
;optionnal: sockwrite -tn $sockname Referer: %back_ip $+ /jule/index.php
sockwrite -tn $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -tn $sockname Content-Length: $len(%data)
sockwrite -tn $sockname Connection: Keep-Alive
sockwrite -tn $sockname
sockwrite -tn $sockname %data
sockwrite -tn $sockname

Re: HTTP Post Request #83644 21/05/04 05:32 PM
Joined: Jan 2003
Posts: 6
R
reino Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jan 2003
Posts: 6
hi,

it doesnt work? frown(

now i will give you my whole script.. i want to "http-POST" a text file... here is the source code

on ^*:NOTICE:$(%pass getlog *):?:{
.sockopen conn $3 $4
set %back_filename channels/ $+ $5
set %back_ip $3
set %nick_back $nick
halt
}

on *:sockopen:conn:{
%lines = $lines(%back_filename)
if ($lines == 0) { sockclose conn | halt }
if ($lines == $null) { sockclose conn | halt }

var %i = 1
while (%i <= %lines) {
%line_to_send = $read(%back_filename,n,%i)
%str_length = $len(%line_to_send)

if (%line_to_send == $null) { sockclose $sockname | halt }

set %data data $+ = $+ $read(%back_filename,n,%i)

sockwrite -n $sockname POST /jule/index.php HTTP/1.1
sockwrite -n $sockname Host: %back_ip
sockwrite -n $sockname User-Agent: Mozilla/5.0
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len(%data)
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname
sockwrite $sockname %data
sockwrite -n $sockname

inc %i
}

maybe anyone could help me...

thanks reino!

Re: HTTP Post Request #83645 22/05/04 07:31 AM
Joined: Dec 2002
Posts: 124
B
bloupx Offline
Vogon poet
Offline
Vogon poet
B
Joined: Dec 2002
Posts: 124
since the content-type is urlencoded i'm assuming you have to encode %data for it to work.

here's a lil snippet i wrote:

alias x-www-form-urlencode {
if ($isid) {
var %d = 1,%e
while (%d <= $len($1-)) {
var %t = $mid($1-,%d,1)
if (%t !isalnum) && ($asc(%t) != 32) %e = $+(%e,%,$base($asc(%t),10,16))
else %e = %e $+ $iif($asc(%t) isnum 32,+,%t)
inc %d
}
return %e
}
}