Can't convert form data to URL - http

I'm trying to send a POST request to get a file downloaded, but I'm having problem complete this operation using URL.
The form looks like this:
<FORM action='download.php' method='post' encType='multipart/form-data'>
<TD bgcolor="white" valign="top" style="padding:10px;">
<TABLE cellspacing=0 cellpadding=0 width='100%'>
<TR>
<TD width='30%' align='center'>
Uploaded torrent code (date+hash):<BR>
<INPUT size=58 name="ref" value="1333f4f84bb41d5adc0f61e8f5a4658460da70b2737" style="font-size:10px;"><INPUT TYPE="hidden" NAME="reff" value="MTM3OTU2Mjk4OQ=="><BR>
downloaded: 27988<BR>
<INPUT type="submit" height=27 width=174 value=download border=0 name=submit valign="bottom" onclick="setpos(1);">
</TD>
</TR>
</TABLE>
</TD>
</FORM>
So I tried to use URL:
www.site.com/download.php?ref=1333f4f84bb41d5adc0f61e8f5a4658460da70b2737
but that doesn't work. Chrome seems to show me a browser based form data:
------WebKitFormBoundaryeqA3pQupG0ndfLMZ
Content-Disposition: form-data; name="ref"
1333f4f84bb41d5adc0f61e8f5a4658460da70b2737
------WebKitFormBoundaryeqA3pQupG0ndfLMZ
Content-Disposition: form-data; name="reff"
MTM3OTQ4NzQwMQ==
------WebKitFormBoundaryeqA3pQupG0ndfLMZ
Content-Disposition: form-data; name="submit"
download
------WebKitFormBoundaryeqA3pQupG0ndfLMZ--
What should I do now?

Post request can't be made in browser url.
-> This is is first way to do this
Sample post request using curl:
curl -F param1=val1 -F param2=val2 -F param3=val3 http://host:port/abc.json
Hit this in terminal/console/cmd
curl -F ref=1333f4f84bb41d5adc0f61e8f5a4658460da70b2737 www.site.com/download.php
-> Or install RestConsole in chrome browser using Google Web Store. There you can handle every kind of request.

Related

How to embed file content into body of the email using mail command?

I have requirement,where i need to send file content as mail body.can we dot through unix scripting.
Thanks in Advance
With the data create a html file. And then send that file in email as content.
use an expression to create your file data like this -
v_data= ' <tr>
<td>'||company ||'</td>
<td>'|| contact_person|| '</td>
<td>'|| country ||'</td>
</tr>'
Use an aggregator to concat all these data into one single row. group by none.
Then use another expression transformation.
create a ports like this -
v_head ='
<head></head>
<body>
<b>pls find below data.</b>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>'
v_body = Aggregated_v_data
v_tail='</table></body>'
v_output = v_head||v_body ||v_tail
Then use this output and connect to a flat file target.
Then send this flat file sing mailx command/any mail client.
Output should look like this.
html file should looks like this
<head></head>
<body>
pls find below data.
<br> </br>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds </td>
<td>Maria </td>
<td>Germany</td>
</tr>
</table>
</body>

Why Transfer-Encoding request header does not interpret correctly?

Here is the PHP code for pg3.php:
<html>
<body>
<form method="post" action="pg3.php">
<h2><font color="red">::Welcome to Server1: 172.16.24.150::</font></h2>
<input type="text" name="user">
<input type="submit" value="Submit">
</body>
</html>
<?php
if(!empty($_POST["user"])){
echo $_POST["user"];
}
?>
I sent the following request:
curl --data "8\r\nuser=mehran\r\n0\r\n" --header "Transfer-Encoding: chunked" "http://172.16.17.10/pg3.php"
I got the following response:
<html>
<body>
<form method="post" action="pg3.php">
<h2><font color="red">::Welcome to Server1: 172.16.24.150::</font></h2>
<input type="text" name="user">
<input type="submit" value="Submit">
</body>
</html>
As the above shows, user=meh is not in the response, while it must be there if Transfer-Encoding works correctly.
What's the problem??
TNX.
See this example in the documentation:
You send a chunked POST with curl like this:
curl -H "Transfer-Encoding: chunked" -d "payload to send" http://example.com
You don't need to try to create the chunked encoded payload yourself. In your case:
curl --data "user=mehran" --header "Transfer-Encoding: chunked" "http://172.16.17.10/pg3.php"
is enough for curl to send:
POST / HTTP/1.1
...
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded
b
user=mehran
0

Power Automate Send Email via SP HTTPS not sending to specific addresses

I have setup a HTTPS request to SharePoint action in PowerAutomate, Using the Uri _api/SP.Utilities.Utility.SendEmail
In the Body, I have 'To': ['myemail#email.com','friendemail#email.com'], along with the rest
In this case the request works and we both receive the email.
However if this changes to ['myemail#email.com','anotherfriendsemail#email.com'] then I receive the email both the other friend does not nor are they listed in the emails To field.
myself and my friend are both owners of the SharePoint site and all parties are part of the same business. The other friend is not a member of the SP site though I tried adding them as an member and then owner and neither worked.
Why does this send to just myself and my friend but not to the other address?
The Error mesage is:
{ "status": 400, "message": "{\"odata.error\":{\"code\":\"-2130242040,Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The e-mail message cannot be sent. Make sure the e-mail has a valid recipient.\"}}}\r\nclientRequestId: RecipientID\r\nserviceRequestId: RequestID", "source": "https://hwinc.sharepoint.com/sites/SiteName/_api/SP.Utilities.Utility.SendEmail", "errors": []}
Edit: Full Body Below
Method: Post
Uri: _api/SP.Utilities.Utility.SendEmail
Headers: accept application/json;odata=nometadata
content-type application/json;odata=nometadatae
Body: {
'properties':{
'From': 'Sharpoint_Site_Name#hwinc.onmicrosoft.com',
'To': ['FirstName.LastName#company.com.au','ABC_Sector#company.com.au'],
'Body': '<p>The Following Order has been Approved:<br><br></p>
<table>
<tr> <td>Approver:</td> <td>#{outputs('Start_and_wait_for_an_approval')?['body/responder/displayName']}</td> </tr>
<tr><td>Date of Order:</td><td>#{outputs('Get_response_details')?['body/rfe2e26ab18544ebea75d9b17a5d84af1']}</td></tr>
<tr> <td>Company:</td> <td>#{outputs('Get_response_details')?['body/rcd9f1c32a2364690ae6d6dbbb049a306']}</td> </tr>
<tr> <td>Customer Name:</td> <td>#{outputs('Get_response_details')?['body/r8a29c2d61ac54342a77d1604bd9f796e']}</td> </tr>
<tr> <td>Address:</td> <td>#{outputs('Get_response_details')?['body/r343a56a5c4ac4f55b11e37c5c3a3f0d4']}</td> </tr>
<tr> <td>Estimated Qty:</td> <td>#{outputs('Get_response_details')?['body/r8a28c14eddca4884833443357035c7eb']}</td> </tr>
<tr> <td>Required Mix:</td> <td>#{outputs('Get_response_details')?['body/r2b9c2f804efe49509436a2c44afe4a83']}</td> </tr>
<tr> <td>Boral Plant Name:</td> <td>#{outputs('Get_response_details')?['body/rcc43d77ecc6f4083ac6d3fbf59ffee75']}</td> </tr>
<tr> <td>Plant Code</td> <td>#{outputs('Get_response_details')?['body/r4fd7f3aceb164a67baece47df43933ee']}</td> </tr>
<tr> <td>3rd Party Supplier:</td> <td>#{variables('3rd Party')}</td> </tr>
<tr> <td>Price:</td> <td>#{outputs('Format_Final_Price')?['body']}</td> </tr>
</table>
<p>Kind regards</p>
#{outputs('Start_and_wait_for_an_approval')?['body/responder/displayName']}',
'Subject': 'Urgent! 3rd Party Purchase Order Request'
}
}

Crawler4j missing outgoing links?

I'm trying to crawl the Apache Mailing Lists to get all the archived messages using Crawler4j. I provided a seed URL and am trying to get links to the other messages. However, it seems to not be extracting all the links.
Following is the HTML of my seed page (http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3CCAOG_4QZ-yyrcwTpRu-8eu6VoUoM3%3DAo_J8Linhpnc%2B6y7tOcxg%40mail.gmail.com%3E):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Re: some healthy broker disappear from zookeeper</title>
<link rel="stylesheet" type="text/css" href="/archives/style.css" />
</head>
<body id="archives">
<h1>kafka-users mailing list archives</h1>
<h5>
Site index · List index</h5> <table class="static" id="msgview">
<thead>
<tr>
<th class="title">Message view</th>
<th class="nav">« Date » · « Thread »</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="title">Top</th>
<th class="nav">« Date » · « Thread »</th>
</tr>
</tfoot>
<tbody>
<tr class="from">
<td class="left">From</td>
<td class="right">Neha Narkhede <neha.narkh...#gmail.com></td>
</tr>
<tr class="subject">
<td class="left">Subject</td>
<td class="right">Re: some healthy broker disappear from zookeeper</td>
</tr>
<tr class="date">
<td class="left">Date</td>
<td class="right">Tue, 20 Nov 2012 19:01:56 GMT</td>
</tr>
<tr class="contents"><td colspan="2"><pre>
zookeeper server version is 3.3.3 is pretty buggy and has known
session expiration and unexpected ephemeral node deletion bugs.
Please upgrade to 3.3.4 and retry.
Thanks,
Neha
On Tue, Nov 20, 2012 at 10:42 AM, Xiaoyu Wang <xwang#rocketfuel.com> wrote:
> Hello everybody,
>
> We have run into this problem a few times in the past week. The symptom is
> some broker disappear from zookeeper. The broker appears to be healthy.
> After that, producers start producing lots of ZK producer cache stale log
> and stop making any progress.
> "logger.info("Try #" + numRetries + " ZK producer cache is stale.
> Refreshing it by reading from ZK again")"
>
> We are running kafka 0.7.1 and the zookeeper server version is 3.3.3.
>
> The missing broker will show up in zookeeper after we restart it. My
> question is
>
> 1. Did anyone encounter the same problem? how did you fix it?
> 2. Why producer is not making any progress? Can we make the producer
> work with those brokers that are listed in zookeeper.
>
>
> Thanks,
>
> -Xiaoyu
</pre></td></tr>
<tr class="mime">
<td class="left">Mime</td>
<td class="right">
<ul>
<li><a rel="nofollow" href="/mod_mbox/kafka-users/201211.mbox/raw/%3cCAOG_4QZ-yyrcwTpRu-8eu6VoUoM3=Ao_J8Linhpnc+6y7tOcxg#mail.gmail.com%3e/">Unnamed text/plain</a> (inline, None, 1037 bytes)</li>
</ul>
</td>
</tr>
<tr class="raw">
<td class="left"></td>
<td class="right">View raw message</td>
</tr>
</tbody>
</table>
</body>
</html>
These are the outgoing URLs as identified by Crawler4j.
http://mail-archives.apache.org/archives/style.css
http://mail-archives.apache.org/mod_mbox/
http://mail-archives.apache.org/mod_mbox/kafka-users
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/date
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/thread
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3CCAOG_4QZ-yyrcwTpRu-8eu6VoUoM3%3DAo_J8Linhpnc%2B6y7tOcxg%40mail.gmail.com%3E
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/date
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/thread
However, the URLs that I'm interested in are missing.
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3cCAFbh0Q1uJGxQiH15a7xS+pCwq+Jft9yKhb66t_C78UrMX338mQ#mail.gmail.com%3e
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3cCAA+BczTexvtqSK+nmauvj37vhTF31awzeegpWdk6eZ-+LaGTVw#mail.gmail.com%3e
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3cCAPkvrnkTEtfFhYnCMj=xMs58pFU1sy-9sJuJ6e19mGVVipRg0A#mail.gmail.com%3e
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3cCAA+BczS5JOCA+QpgLU+tXeG=Ke_MXxiG_PinMt0YDxGBtz5nPg#mail.gmail.com%3e
What am I doing wrong? How do I get Crawler4j to extract the URLs I need?
Please tell me you have noticed there are direct links for downloading mbox files for mailing lists. In your case, just wget this, no crawler needed:
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox
You are probably giving the wrong seed page.
I think your seed page should be:
http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/thread
and then use
public boolean shouldVisit(WebURL url) {
String href = url.getURL().toLowerCase();
return (!FILTERS.matcher(href).matches() && href.contains("http://mail-archives.apache.org/mod_mbox/kafka-users/201211.mbox/%3cCA"));
}
I hope that helps.

curl + jsecurity authentication

I have a grails app that is using jsecurity plugin for authentication.
How do I use curl to send my credentials? If I just do curl -u username mysite
I get a prompt for a password, then nothing.
I tried to do an anyauth command and this is what I got for the site. Any idea why it is returning a 302?
dcole#DCOLE-L /cygdrive/c/dev
$ curl --anyauth --verbose http://localhost:8080/SkillsDB
* About to connect() to localhost port 8080 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
> GET /SkillsDB HTTP/1.1
> User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8o zlib/1.
2.5 libidn/1.18 libssh2/1.2.5
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
< Server: Apache-Coyote/1.1
< Location: http://localhost:8080/SkillsDB/
< Transfer-Encoding: chunked
< Date: Thu, 07 Oct 2010 14:32:32 GMT
<
* Connection #0 to host localhost left intact
* Closing connection #0
here is additional information:
Rob is correct that it is form based. When I go to the address
http://localhost:8080/SkillsDB/auth/initialLogin
This is the form code that is displayed:
<form action="/SkillsDB/auth/initialSignIn" method="post" name="logform" id="logform">
<input name="targetUri" value="" type="hidden">
<input value="" widgetid="username" tabindex="0" id="username" class="dijit dijitReset dijitLeft dijitTextBox" dojoattachpoint="textbox,focusNode" name="username" dojoattachevent="onmouseenter:_onMouse,onmouseleave:_onMouse,onfocus:_onMouse,onblur:_onMouse,onkeypress:_onKeyPress" autocomplete="off" type="text"></td>
<input value="" widgetid="password" tabindex="0" id="password" class="dijit dijitReset dijitLeft dijitTextBox" dojoattachpoint="textbox,focusNode" name="password" dojoattachevent="onmouseenter:_onMouse,onmouseleave:_onMouse,onfocus:_onMouse,onblur:_onMouse,onkeypress:_onKeyPress" autocomplete="off" type="password"></td>
<td style=""><span widgetid="dijit_form_Button_0" class="dijit dijitReset dijitLeft dijitInline dijitButton" dojoattachevent="ondijitclick:_onButtonClick,onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse"><span class="dijitReset dijitRight dijitInline"><span class="dijitReset dijitInline dijitButtonNode"><button style="-moz-user-select: none;" tabindex="0" value="Log In" id="dijit_form_Button_0" aria-labelledby="dijit_form_Button_0_label" role="button" class="dijitReset dijitStretch dijitButtonContents" dojoattachpoint="titleNode,focusNode" name="" type="submit" wairole="button" waistate="labelledby-dijit_form_Button_0_label"><span class="dijitReset dijitInline" dojoattachpoint="iconNode"><span class="dijitReset dijitToggleButtonIconChar">✓</span></span><span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_0_label" dojoattachpoint="containerNode">Log In</span></button></span></span></span></td>
</form>
If you're using a form-based authentication method, it's likely you're going to have to make an HTTP POST request to your login form, something along the lines of:
curl --data="username=foo&password=bar" http://localhost:8080/SkillsDB/login/auth
# note that '--data' causes the request to be a POST
I can't remember what JSecurity's login action is, but you'll have to replace login/auth (in the curl command above) with it. Have a look at the action of the <form> that the login page submits to.
Note that you'll be passing the password as plain text here. You'll probably want to use HTTPS for this transaction, but that's a whole different question.
Unless JSecurity is extending its authentication to use HTTP Basic Authentication, using the --anyauth is not likely to work, as I would imagine curl uses that to determine the proper HTTP authentication method.
Regarding your question about the 302, what happens when you add --location to your curl arguments? That should make curl follow the Location header that comes back in the response.

Resources