nurul | 1 Nov 2010 05:50
Picon

question on POST

Hello all,

I'm very new to curl, so pardon me if this is question is inappropriate etc.

According to:
http://curl.haxx.se/docs/httpscripting.shtml

<form method="POST" action="junk.cgi">
<input type=text name="birthyear">
<input type=submit name=press value="OK">
</form>

And to use curl to post this form with the same data filled in as before, we
could do it like:

curl -d "birthyear=1905&press=OK" www.hotmail.com/when/junk.cgi

However it seems like my case is a bit complex. The form goes like this

<FORM METHOD="POST" action="/cgi-bin/targetRNA/processRequest_2.cgi" ENCTYPE="application/x-www-form-urlencoded" NAME="form1">
<SELECT NAME = "organism">
     <OPTION>&nbsp;</OPTION>
</SELECT>

<input TYPE="text" NAME="mRNA" SIZE="10">
<input TYPE="submit" VALUE="SEARCH">
</FORM>

I need to specify three values in this.

1) The first one is the organism from a dynamically populated list, in the <SELECT> part. my value for this will always be an organism called 'Burkholderia Pseudomallei'. I have no idea how to do this.
2) Secondly is the mRNA, which isn't a problem since it has a 'name'
3) Thirdly is the submit value, which is a problem since it doesn't have a 'name'

Could anyone give me any pointers how to do this?
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Daniel Stenberg | 1 Nov 2010 09:14
Picon
Favicon
Gravatar

Re: question on POST

On Mon, 1 Nov 2010, nurul wrote:

> http://curl.haxx.se/docs/httpscripting.shtml

> Could anyone give me any pointers how to do this?

Sure, the section 14 on the above mentioned docs does explain a sensible way 
to proceed forward.

LiveHTTPHeader (or equivalent) is your friend. Figure out what your browser 
sends in the case you want to do with curl, then make sure your curl command 
line sends the same thing.

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Skrzyniarz Alexandre | 4 Nov 2010 09:35

Bug in sftp timeout detection.

Hello. We found this little issue with curl:

Timeout setting with -Y and -y options doesn't work with sftp protocol.

curl --version
curl 7.21.2 (i686-pc-linux-gnu) libcurl/7.21.2 OpenSSL/0.9.7a
zlib/1.2.1.2 libidn/0.5.6 libssh2/1.1 Protocols: dict file ftp ftps
gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp
smtps telnet tftp Features: IDN IPv6 Largefile NTLM SSL libz

Error reproduction:
install a sftp server, and use curl as such:

curl  -y 10 -Y 1 --connect-timeout 10 -o /dest/file  -m 1200 -u
user:password sftp://server//from//file.txt

unplug the network cable: no timeout.

note: when transfering the same file via http, timeout works.

--

-- 
Alexandre SKRZYNIARZ, PhD.
[EXPERTS] Domain Design Authority, Radar & Warfare Systems.
THALES AIRBORNE SYSTEMS
10 Av 1ere DFL, 29200 BREST, France
email: alexandre.skrzyniarz <at> fr.thalesgroup.com
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Daniel Stenberg | 4 Nov 2010 14:23
Picon
Favicon
Gravatar

Re: Bug in sftp timeout detection.

On Thu, 4 Nov 2010, Skrzyniarz Alexandre wrote:

> Timeout setting with -Y and -y options doesn't work with sftp protocol.

> curl  -y 10 -Y 1 --connect-timeout 10 -o /dest/file  -m 1200 -u
> user:password sftp://server//from//file.txt

How curious. Does the progress meter still continue to update itself during 
this time?

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Tubati Narasimham | 4 Nov 2010 14:54
Picon

HTTP Error 401.2


Hi ,

I am getting the below error while using the curl for http post 

HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2>


The WAS for the above mentioned url is a shared environment is protected via OAM. Can we use curl for such environments for doing http post ? Did anyone get this error for such environment? Thanks In Advance.




--
Regards
Tubati
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Daniel Stenberg | 4 Nov 2010 16:27
Picon
Favicon
Gravatar

Re: HTTP Error 401.2

On Thu, 4 Nov 2010, Tubati Narasimham wrote:

> HTTP Error 401.2 - Unauthorized: Access is denied due to server
> configuration.<br>Internet Information Services (IIS)</h2>

Then check the response headers to see what kind of auth method it wants. Use 
-v for example.

> Command : curl -k -L -d  <at> maxobj.xml
> http://wwwin-tools-dev-was6.cisco.com/itam/maximo/meaweb/es/XXAMS_MAXOBJECT/XXAMS_MAXCONFIG_Q-u
> ntubati:******

I hope you intended that -u to have a space in front of it.

> The WAS for the above mentioned url is a shared environment is protected via 
> OAM.

The WAS? OAM? Sorry, I don't know what those are.

> Can we use curl for such environments for doing http post ?

If it uses one of the auth methods curl supports, yes!

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Skrzyniarz Alexandre | 4 Nov 2010 16:39

Re: Bug in sftp timeout detection.

On Thu, 4 Nov 2010 14:23:38 +0100 (CET)
Daniel Stenberg <daniel <at> haxx.se> wrote:

> On Thu, 4 Nov 2010, Skrzyniarz Alexandre wrote:
> 
> > Timeout setting with -Y and -y options doesn't work with sftp
> > protocol.
> 
> > curl  -y 10 -Y 1 --connect-timeout 10 -o /dest/file  -m 1200 -u
> > user:password sftp://server//from//file.txt
> 
> How curious. Does the progress meter still continue to update itself
> during this time?
> 

Yes. The displayed download speed falls to zero, but the download isn't
aborted.

--

-- 
Alexandre SKRZYNIARZ, PhD.
[EXPERTS] Domain Design Authority, Radar & Warfare Systems.
THALES AIRBORNE SYSTEMS
10 Av 1ere DFL, 29200 BREST, France
email: alexandre.skrzyniarz <at> fr.thalesgroup.com
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Tubati Narasimham | 4 Nov 2010 17:03
Picon

Re: HTTP Error 401.2

Hi Daniel ,

Here is the authentication method, and regarding the space yeah used a space before -u. I checked in net and could not find pointers on using curl for http post with the authentication method NTLM. Do you have any idea. Thanks for your help

HTTP/1.1 401 Unauthorized
< Date: Thu, 04 Nov 2010 14:57:02 GMT
< Content-Length: 1656
< Content-Type: text/html
< Server: Microsoft-IIS/6.0
< WWW-Authenticate: Negotiate
< WWW-Authenticate: NTLM

Thanks
Tubati

On Thu, Nov 4, 2010 at 11:27 AM, Daniel Stenberg <daniel <at> haxx.se> wrote:
On Thu, 4 Nov 2010, Tubati Narasimham wrote:

HTTP Error 401.2 - Unauthorized: Access is denied due to server
configuration.<br>Internet Information Services (IIS)</h2>

Then check the response headers to see what kind of auth method it wants. Use -v for example. I hope you intended that -u to have a space in front of it.


The WAS for the above mentioned url is a shared environment is protected via OAM.

The WAS? OAM? Sorry, I don't know what those are.


Can we use curl for such environments for doing http post ?

If it uses one of the auth methods curl supports, yes!

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html



--
regards
narasimham
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Daniel Stenberg | 4 Nov 2010 19:21
Picon
Favicon
Gravatar

Re: HTTP Error 401.2

On Thu, 4 Nov 2010, Tubati Narasimham wrote:

Please do not top post, because people tend to read from top to bottom
not the other way around! And trim your quotes, there's no point in resending 
the entire previous mail again.

> I checked in net and could not find pointers on using curl for http post 
> with the authentication method NTLM.

I would recommend the curl documentation. Try 'man curl', 'curl -M' or 
http://curl.haxx.se/docs/manpage.html. --ntlm or --anyauth are likely what you 
want.

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Stefan Tomanek | 5 Nov 2010 00:39
Picon
Gravatar

[PATCH] save URL to extended file attributes

It is often convinient to track back the source of a once downloaded
file; this patch makes curl store the source URL by using the extended
attributes (if supported by the file system and enabled by --xattr).
---
 src/Makefile.inc |    5 +++--
 src/main.c       |   17 +++++++++++++++++
 src/xattr.c      |   36 ++++++++++++++++++++++++++++++++++++
 src/xattr.h      |    1 +
 4 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 src/xattr.c
 create mode 100644 src/xattr.h

diff --git a/src/Makefile.inc b/src/Makefile.inc
index 34dfd45..427ac54 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
 <at>  <at>  -15,11 +15,12  <at>  <at>  CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \
 	$(top_srcdir)/lib/nonblock.c

 CURL_CFILES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
-	getpass.c homedir.c curlutil.c os-specific.c
+	getpass.c homedir.c curlutil.c os-specific.c xattr_url.c

 CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
 	config-riscos.h urlglob.h version.h os-specific.h \
-	writeout.h writeenv.h getpass.h homedir.h curlutil.h
+	writeout.h writeenv.h getpass.h homedir.h curlutil.h \
+	xattr_url.h

 curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)

diff --git a/src/main.c b/src/main.c
index 8a942de..8457edd 100644
--- a/src/main.c
+++ b/src/main.c
 <at>  <at>  -51,6 +51,8  <at>  <at> 
 #endif
 #include "rawstr.h"

+#include "xattr.h"
+
 #define CURLseparator   "--_curl_--"

 #ifdef NETWARE
 <at>  <at>  -621,6 +623,7  <at>  <at>  struct Configurable {
   int default_node_flags; /* default flags to seach for each 'node', which is
                              basically each given URL to transfer */
   struct OutStruct *outs;
+  bool xattr; /* store metadata in extended attributes */
 };

 #define WARN_PREFIX "Warning: "
 <at>  <at>  -906,6 +909,7  <at>  <at>  static void help(void)
     "    --wdebug        Turn on Watt-32 debugging",
 #endif
     " -w/--write-out <format> What to output after completion",
+    " --xattr            Store metadata in extended file attributes",
     " -q                 If used as the first parameter disables .curlrc",
     NULL
   };
 <at>  <at>  -1953,6 +1957,7  <at>  <at>  static ParameterError getparameter(char *flag, /* f or -long-flag */
     {"y", "speed-time", TRUE},
     {"z", "time-cond",   TRUE},
     {"#", "progress-bar",FALSE},
+    {"~", "xattr",FALSE},
   };

   if(('-' != flag[0]) ||
 <at>  <at>  -2445,6 +2450,9  <at>  <at>  static ParameterError getparameter(char *flag, /* f or -long-flag */
       else
         config->progressmode = CURL_PROGRESS_STATS;
       break;
+    case '~': /* --xattr */
+      config->xattr = toggle;
+      break;
     case '0':
       /* HTTP version 1.0 */
       config->httpversion = CURL_HTTP_VERSION_1_0;
 <at>  <at>  -5639,6 +5647,15  <at>  <at>  operate(struct Configurable *config, int argc, argv_item_t argv[])
           }
         }

+        if(config->xattr && outs.filename) {
+          char *url = NULL;
+          curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
+          int err = set_xattr( curl, outs.filename );
+          if (err) {
+            warnf( config, "Error setting extended attributes: %s\n", strerror(errno) );
+          }
+        }
+
 #ifdef HAVE_UTIME
         /* Important that we set the time _after_ the file has been
            closed, as is done above here */
diff --git a/src/xattr.c b/src/xattr.c
new file mode 100644
index 0000000..6b3f9ca
--- /dev/null
+++ b/src/xattr.c
 <at>  <at>  -0,0 +1,36  <at>  <at> 
+#include <sys/types.h>
+#include <attr/xattr.h>
+#include <string.h>
+#include <curl/curl.h>
+#include "xattr.h"
+
+/* mapping table of curl metadata to extended attribute names */
+static struct xattr_mapping {
+  char *attr; /* name of the xattr */
+  CURLINFO info;
+} mappings[] = {
+  /* mappings proposed by
+   * http://freedesktop.org/wiki/CommonExtendedAttributes
+   */
+  { "user.xdg.origin.url", CURLINFO_EFFECTIVE_URL },
+  { "user.mime_type", CURLINFO_CONTENT_TYPE },
+  { NULL, 0 } /* last element, abort loop here */
+};
+
+/* store metadata from the curl request alongside the downloaded
+ * file using extended attributes
+ */
+int set_xattr( CURL *curl, const char *filename ) {
+  int i = 0;
+  int err = 0;
+  /* loop through all xattr-curlinfo pairs and abort on error */
+  while ( err == 0 && mappings[i].attr != NULL ) {
+    char *value = NULL;
+    curl_easy_getinfo(curl, mappings[i].info, &value);
+    if (value) {
+      err = setxattr( filename, mappings[i].attr, value, strlen(value), 0 );
+    }
+    i++;
+  }
+  return err;
+}
diff --git a/src/xattr.h b/src/xattr.h
new file mode 100644
index 0000000..062c46d
--- /dev/null
+++ b/src/xattr.h
 <at>  <at>  -0,0 +1  <at>  <at> 
+int set_xattr( CURL *curl, const char *filename );
--

-- 
1.7.2.3
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Gmane