+  HandyCache форум
|-+  Главная категория» English forum» [ask] how to send POST data ?
Имя пользователя:
Пароль:
Страниц: [1]   Вниз
  Отправить эту тему    Печать  
Автор Тема: [ask] how to send POST data ?  (Прочитано 3456 раз)
0 Пользователей и 1 Гость смотрят эту тему.
shawnthesheep
Новичок
*

Репутация: +0/-0
Offline Offline

Сообщений: 8


« : 05 февраля 2015, 09:00:01 »

Hello Улыбка

is it possible to send POST data using HC ?
I've read the documentation and it said I can use hc.send_request to do that

Цитировать
Arguments to the function:
header - the header http-request;
body - the body of http-request for the method POST.
https_header - heading to form https-request to the proxy server.

this is my extension, I want to ask sitereview.bluecoat.com about site categories and use it for blocking porn

Код:
--[[ <HCExtension>
@name           Web Filter ( blue coat )
@version        1
@event          RequestHeaderReceived/request
@event  Init/init
</HCExtension> ]]

function init()
hc.put_msg(3, 'hc_bluecoat')
end


function request()
if re.find(hc.request_header, [[^Accept:\stext/html]]) then
local crc_r = re.find(hc.url, [[\b([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b]])
local crc_r = hc.crc32(crc_r)
--local pat = hc.cache_path ..'temp\\webfilter\\bluecoat\\'..'data='..crc_r
local hdr = 'POST /rest/categorization HTTP/1.1\r\nHost: sitereview.bluecoat.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0\r\nAccept: */*\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nX-Requested-With: XMLHttpRequest\r\nReferer: http://sitereview.bluecoat.com/sitereview.jsp\r\nConnection: keep-alive\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n'
hc.send_request(hdr, 'url=kaskus.co.id')
end
end

It fails to send the data, i check using charles and the POST data is empty
 
Сообщить модератору   Записан
stealzy
Пользователь
**

Репутация: +1/-2
Offline Offline

Сообщений: 52


« Ответ #1 : 06 февраля 2015, 09:34:04 »

Код:
function init()
local hdr = 'POST /rest/categorization HTTP/1.1\r\nHost: sitereview.bluecoat.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0\r\nAccept: */*\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nX-Requested-With: XMLHttpRequest\r\nReferer: http://sitereview.bluecoat.com/sitereview.jsp\r\nConnection: keep-alive\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n'
hc.send_request(hdr, 'url=kaskus.co.id')
end


function request()
if re.find(hc.request_header, [[^Accept:\stext/html]]) then
hc.put_msg(10, 'If-Then Work!')
local crc_r = re.find(hc.url, [[\b([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b]])
local crc_r = hc.crc32(crc_r)
hc.put_msg(10, crc_r)
--local pat = hc.cache_path ..'temp\\webfilter\\bluecoat\\'..'data='..crc_r
local hdr = 'POST /rest/categorization HTTP/1.1\r\nHost: sitereview.bluecoat.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0\r\nAccept: */*\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nX-Requested-With: XMLHttpRequest\r\nReferer: http://sitereview.bluecoat.com/sitereview.jsp\r\nConnection: keep-alive\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n'
hc.send_request(hdr, 'url=kaskus.co.id')
end
end
Try it.
Add   @event    bluecoat\.com
Why You send POST at the same time with RequestHeaderReceived?
What is the connection between the two phenomena?
When RequestHeaderReceived arise?
« Последнее редактирование: 06 февраля 2015, 09:42:29 от stealzy » Сообщить модератору   Записан

HC 1.0.0.551
shawnthesheep
Новичок
*

Репутация: +0/-0
Offline Offline

Сообщений: 8


« Ответ #2 : 06 февраля 2015, 15:30:48 »

thanks for your reply,
 
I tried your suggestion, the POST request is sent BUT with no data (site=kaskus.co.id)   Грустный
I just want to write a similar extension to this one

http://pastebin.com/GUREVbLx

For every request that HC received, the extension will ask the site category to fortiguard.com
and the extension will filter the request based on the response received from fortiguard.com
we can use GET request at fortiguard but for bluecoat, I need to use POST request

 
Сообщить модератору   Записан
Страниц: [1]   Вверх
  Отправить эту тему    Печать  

 
Перейти в: