Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-11-05 Thread Giuseppe Scrivano
Matthew Atkinson mutley...@ntlworld.com writes:

 I don't think this ever got pushed.

thanks to have checked it.  I've pushed it right now.

Regards,
Giuseppe



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-11-04 Thread Matthew Atkinson
On 21/10/14 09:48, Giuseppe Scrivano wrote:
 Matthew Atkinson mutley...@ntlworld.com writes:
 
 On 20/10/14 21:16, Tim Rühsen wrote:
  
 Since Wget does not explicitly support PUT, we may just care for the POST 
 request. Since servers may reject a POST without Content-Length, we are 
 better 
 off with supplying one. Since PUT (and also PATCH) request 'anticipate' a 
 body, 
 we could also care for these.

 Matthew, could you also check for 'put and 'patch' request and send an 
 amended 
 version of the patch. FYI, HTTP PATCH request is rfc5789.

 Attached
 
 thanks pushed now!  Congratulations on your first contribution to wget.
 
 Regards,
 Giuseppe
 

Hi

I don't think this ever got pushed.

Thanks,
Matt



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-23 Thread Matthew Atkinson
On 21/10/14 09:48, Giuseppe Scrivano wrote:

 thanks pushed now!  Congratulations on your first contribution to wget.
 
 Regards,
 Giuseppe
You sure, or am I being a bit thick? My git is pointing at
git://git.savannah.gnu.org/wget.git and not seeing it

Thanks,
Matt



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-22 Thread Tim Rühsen
Am Dienstag, 21. Oktober 2014, 09:39:25 schrieb Matthew Atkinson:
 On 20/10/14 21:16, Tim Rühsen wrote:
  Since Wget does not explicitly support PUT, we may just care for the POST
  request. Since servers may reject a POST without Content-Length, we are
  better off with supplying one. Since PUT (and also PATCH) request
  'anticipate' a body, we could also care for these.
  
  Matthew, could you also check for 'put and 'patch' request and send an
  amended version of the patch. FYI, HTTP PATCH request is rfc5789.
 
 Attached

Good work, thanks !

Tim

signature.asc
Description: This is a digitally signed message part.


Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-21 Thread Matthew Atkinson
On 20/10/14 21:16, Tim Rühsen wrote:
 
 Since Wget does not explicitly support PUT, we may just care for the POST 
 request. Since servers may reject a POST without Content-Length, we are 
 better 
 off with supplying one. Since PUT (and also PATCH) request 'anticipate' a 
 body, 
 we could also care for these.
 
 Matthew, could you also check for 'put and 'patch' request and send an 
 amended 
 version of the patch. FYI, HTTP PATCH request is rfc5789.

Attached
From 0bc85a619677dc8a0313a5596497d42190fb3452 Mon Sep 17 00:00:00 2001
From: Matthew Atkinson mutley...@ntlworld.com
Date: Tue, 21 Oct 2014 09:28:45 +0100
Subject: [PATCH] Always send Content-Length with POST, PUT, PATCH

---
 src/ChangeLog | 6 ++
 src/http.c| 4 
 2 files changed, 10 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index d5aeca0..0f92db5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-21  Matthew Atkinson  mutley...@ntlworld.com
+
+	* http.c (gethttp): Always send Content-Length header when method is POST,
+	PUT, or PATCH even with no post body, as some servers will reject the
+	request otherwise
+
 2014-10-16  Tim Ruehsen  tim.rueh...@gmx.de
 
 	* url.c (url_parse): little code cleanup
diff --git a/src/http.c b/src/http.c
index 4b99c17..2469852 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1875,6 +1875,10 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
   xstrdup (number_to_static_string (body_data_size)),
   rel_value);
 }
+  else if (strcasecmp (opt.method, post) == 0
+   || strcasecmp (opt.method, put) == 0
+   || strcasecmp (opt.method, patch) == 0)
+request_set_header (req, Content-Length, 0, rel_none);
 }
 
  retry_with_auth:
-- 
1.9.1



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-21 Thread Giuseppe Scrivano
Matthew Atkinson mutley...@ntlworld.com writes:

 On 20/10/14 21:16, Tim Rühsen wrote:
  
 Since Wget does not explicitly support PUT, we may just care for the POST 
 request. Since servers may reject a POST without Content-Length, we are 
 better 
 off with supplying one. Since PUT (and also PATCH) request 'anticipate' a 
 body, 
 we could also care for these.
 
 Matthew, could you also check for 'put and 'patch' request and send an 
 amended 
 version of the patch. FYI, HTTP PATCH request is rfc5789.

 Attached

thanks pushed now!  Congratulations on your first contribution to wget.

Regards,
Giuseppe



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-20 Thread Giuseppe Scrivano
Matthew Atkinson mutley...@ntlworld.com writes:

 diff --git a/src/ChangeLog b/src/ChangeLog
 index 1c4e2d5..447179e 100644
 --- a/src/ChangeLog
 +++ b/src/ChangeLog
 @@ -1,3 +1,8 @@
 +2014-10-19  Matthew Atkinson  mutley...@ntlworld.com
 +
 + * http.c (gethttp): Always send Content-Length header when method is 
 post,
 + even with no post body, as some servers will reject the request 
 otherwise
 +
  2014-05-03  Tim Ruehsen  tim.rueh...@gmx.de
  
   * retr.c (retrieve_url): fixed memory leak
 diff --git a/src/http.c b/src/http.c
 index 4b99c17..e020682 100644
 --- a/src/http.c
 +++ b/src/http.c
 @@ -1875,6 +1875,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, 
 struct url *proxy,
xstrdup (number_to_static_string 
 (body_data_size)),
rel_value);
  }
 +  else if (strcasecmp (opt.method, post) == 0)
 +request_set_header (req, Content-Length, 0, rel_none);

should we do this only for POST requests?  What about doing it in any
case that !(opt.body_data || opt.body_file)?

Regards,
Giuseppe



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-20 Thread Matthew Atkinson
On 20/10/14 16:26, Giuseppe Scrivano wrote:
 should we do this only for POST requests?  What about doing it in any
 case that !(opt.body_data || opt.body_file)?
 
 Regards,
 Giuseppe

From http://tools.ietf.org/html/rfc7230#section-3.3.2
 A user agent SHOULD send a Content-Length in a request message when
 no Transfer-Encoding is sent and the request method defines a
 meaning for an enclosed payload body.  For example, a Content-Length
 header field is normally sent in a POST request even when the value
 is 0 (indicating an empty payload body).  A user agent SHOULD
 NOT send a Content-Length header field when the request message
 does not contain a payload body and the method semantics do not
 anticipate such a body.

I would think that we should do this for POST and PUT, but nothing
else

Thanks,
Matt



Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-20 Thread Darshit Shah
I think we should handle PUT and POST alone. And add additional logic to
handle a 411 response to any request.

Wget has traditionally supported POST requests and PUT has a very similar
usage, for anything else, the user should use the - - send-header commands.
On 20-Oct-2014 1:16 pm, Tim Rühsen tim.rueh...@gmx.de wrote:

Am Montag, 20. Oktober 2014, 20:08:05 schrieb Matthew Atkinson:
 On 20/10/14 16:26, Giuseppe Scrivano wrote:
  should we do this only for POST requests?  What about doing it in any
  case that !(opt.body_data || opt.body_file)?
 
  Regards,
  Giuseppe

 From http://tools.ietf.org/html/rfc7230#section-3.3.2

  A user agent SHOULD send a Content-Length in a request message when
  no Transfer-Encoding is sent and the request method defines a
  meaning for an enclosed payload body.  For example, a Content-Length
  header field is normally sent in a POST request even when the value
  is 0 (indicating an empty payload body).  A user agent SHOULD
  NOT send a Content-Length header field when the request message
  does not contain a payload body and the method semantics do not
  anticipate such a body.

 I would think that we should do this for POST and PUT, but nothing
 else

Since Wget does not explicitly support PUT, we may just care for the POST
request. Since servers may reject a POST without Content-Length, we are
better
off with supplying one. Since PUT (and also PATCH) request 'anticipate' a
body,
we could also care for these.

Matthew, could you also check for 'put and 'patch' request and send an
amended
version of the patch. FYI, HTTP PATCH request is rfc5789.


RFC 7230
3.3.2. Content-Length

   A user agent SHOULD send a Content-Length in a request message when
   no Transfer-Encoding is sent and the request method defines a meaning
   for an enclosed payload body.  For example, a Content-Length header
   field is normally sent in a POST request even when the value is 0
   (indicating an empty payload body).  A user agent SHOULD NOT send a
   Content-Length header field when the request message does not contain
   a payload body and the method semantics do not anticipate such a
   body.


RFC7231
6.5.10. 411 Length Required

   The 411 (Length Required) status code indicates that the server
   refuses to accept the request without a defined Content-Length
   (Section 3.3.2 of [RFC7230]).  The client MAY repeat the request if
   it adds a valid Content-Length header field containing the length of
   the message body in the request message.


Tim


[Bug-wget] Send Content-Length with POST 0 length body

2014-10-19 Thread Matthew Atkinson

Hi

I was looking through the list archives to find something that useful I 
could contribute to wget and get familiar with the code, I have attached 
a patch for the following.


Darshit Shah darnir at gmail.com wrote on 2014-09-05 07:31:34 GMT
The Content-Length Header is expected by the server in many requests,
most prominently in a POST Request. However, currently if a POST
request is sent without any body, Wget does not send any
Content-Length headers. Some servers seem to dislike this behaviour
and respond with a 411 Length Required message.
Patch Wget to always send a Content-Length header when the Request 
Type is POST.


Hopefully I can find something less trivial to add or fix in the future, 
any suggestions, direction or feedback, please let me know.


Thanks,
Matt
diff --git a/src/http.c b/src/http.c
index 4b99c17..e020682 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1875,6 +1875,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
   xstrdup (number_to_static_string (body_data_size)),
   rel_value);
 }
+  else if (strcasecmp (opt.method, post) == 0)
+request_set_header (req, Content-Length, 0, rel_none);
 }
 
  retry_with_auth:


Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-19 Thread Tim Rühsen
Am Sonntag, 19. Oktober 2014, 11:27:51 schrieb Matthew Atkinson:
 Hi
 
 I was looking through the list archives to find something that useful I
 could contribute to wget and get familiar with the code, I have attached
 a patch for the following.
 
 Darshit Shah darnir at gmail.com wrote on 2014-09-05 07:31:34 GMT
 
  The Content-Length Header is expected by the server in many requests,
  most prominently in a POST Request. However, currently if a POST
  request is sent without any body, Wget does not send any
  Content-Length headers. Some servers seem to dislike this behaviour
  and respond with a 411 Length Required message.
  Patch Wget to always send a Content-Length header when the Request
  Type is POST.
 
 Hopefully I can find something less trivial to add or fix in the future,
 any suggestions, direction or feedback, please let me know.

Very good ! Thanks for your work.

There two little things - well, just kinda organizational work:

1. Please also extend src/ChangeLog and include it in your patch
2. The maintainers will ask you for a 'git format-patch' output
  If you never worked with that:
  - git commit your change(s)
  - attach the files generated with 'git format-patch -1'

Thank you

Tim


signature.asc
Description: This is a digitally signed message part.


Re: [Bug-wget] Send Content-Length with POST 0 length body

2014-10-19 Thread Matthew Atkinson
On 19/10/14 19:34, Tim Rühsen wrote:
 There two little things - well, just kinda organizational work:
 
 1. Please also extend src/ChangeLog and include it in your patch
 2. The maintainers will ask you for a 'git format-patch' output
   If you never worked with that:
   - git commit your change(s)
   - attach the files generated with 'git format-patch -1'

Attached

Thanks,
Matt
From af9326b1665e0e1d3b28ed0b66c6c99d07a88172 Mon Sep 17 00:00:00 2001
From: Matthew Atkinson mutley...@ntlworld.com
Date: Sun, 19 Oct 2014 21:31:36 +0100
Subject: [PATCH] Always send Content-Length if method is post

---
 src/ChangeLog | 5 +
 src/http.c| 2 ++
 2 files changed, 7 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 1c4e2d5..447179e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-19  Matthew Atkinson  mutley...@ntlworld.com
+
+	* http.c (gethttp): Always send Content-Length header when method is post,
+	even with no post body, as some servers will reject the request otherwise
+
 2014-05-03  Tim Ruehsen  tim.rueh...@gmx.de
 
 	* retr.c (retrieve_url): fixed memory leak
diff --git a/src/http.c b/src/http.c
index 4b99c17..e020682 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1875,6 +1875,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
   xstrdup (number_to_static_string (body_data_size)),
   rel_value);
 }
+  else if (strcasecmp (opt.method, post) == 0)
+request_set_header (req, Content-Length, 0, rel_none);
 }
 
  retry_with_auth:
-- 
1.9.1