Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Steve Dondley
This wouldn't qualify as an "obvious" bug if the RFC stipulated that all 
parts of type "application/type" had to have a blank line before the 
boundary. I have no idea if it does or doesn't, of course. But that would 
be something very hard to know and be "non-obvious."

At any rate, Google seems to require the extra blank line. Either they have 
deviated from the RFC or team Mojolicious has. Google isn't known for 
overlooking obvious bugs either.

On Tuesday, September 18, 2018 at 2:52:59 PM UTC-4, sri wrote:
>
> Now the question is, is this a mojolicious bug or not? Is the content 
>> inside of a multipart post request required to have a blank line after it?
>>
>
> We don't have bugs this obvious. You appear to be misunderstanding what's
> happening there. Those multipart parts appear to be properly formatted HTTP
> requests.
>
> --
> sebastian
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread sri

>
> Now the question is, is this a mojolicious bug or not? Is the content 
> inside of a multipart post request required to have a blank line after it?
>

We don't have bugs this obvious. You appear to be misunderstanding what's
happening there. Those multipart parts appear to be properly formatted HTTP
requests.

--
sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Steve Dondley
I figure it out! So, I needed to throw in a blank line (\r\n) at the end of 
the GET request inside of the POST request. 

Now the question is, is this a mojolicious bug or not? Is the content 
inside of a multipart post request required to have a blank line after it?

On Tuesday, September 18, 2018 at 1:48:07 PM UTC-4, Dan Book wrote:
>
> I think you missed something in my post. You should not need to add any 
> content length headers yourself.
>
> -Dan
>
> On Tue, Sep 18, 2018 at 1:28 PM Steve Dondley  > wrote:
>
>> Thanks. It doesn't look like adding the content-length helped. Still 
>> getting 400 errors. And I just noticed that in Google's example there is no 
>> content-length header for a GET request. Don't know what else to try now.
>>
>> On Tuesday, September 18, 2018 at 1:06:23 PM UTC-4, Dan Book wrote:
>>>
>>> These "parts" are essentially embedded HTTP requests; the lines under 
>>> each listed GET/PUT/etc are headers for that embedded request. Here is the 
>>> structure of their example annotated:
>>>
>>> POST /batch/farm/v1 HTTP/1.1 # actual request and headers
>>> Authorization: Bearer your_auth_token
>>> Host: www.googleapis.com
>>> Content-Type: multipart/mixed; boundary=batch_foobarbaz
>>> Content-Length: total_content_length
>>> # rest is actual request content
>>> --batch_foobarbaz # first multipart segment
>>> Content-Type: application/http # multipart segment headers
>>> Content-ID: 
>>>
>>> GET /farm/v1/animals/pony # multipart segment *content*
>>>
>>> --batch_foobarbaz # second multipart segment
>>> Content-Type: application/http # multipart segment headers
>>> Content-ID: 
>>>
>>> PUT /farm/v1/animals/sheep # multipart segment *content*
>>> Content-Type: application/json
>>> Content-Length: part_content_length
>>> If-Match: "etag/sheep"
>>>
>>> {
>>>   "animalName": "sheep",
>>>   "animalAge": "5"
>>>   "peltColor": "green",
>>> }
>>>
>>> --batch_foobarbaz # third multipart segment
>>> Content-Type: application/http # multipart segment headers
>>> Content-ID: 
>>>
>>> GET /farm/v1/animals # multipart segment *content*
>>> If-None-Match: "etag/animals"
>>>
>>> --batch_foobarbaz--
>>>
>>> As noted the part where the part_content_length is is inside the content 
>>> for one of the multipart segments. Mojolicious doesn't have anything to 
>>> deal with the content of multipart segments of this type, so you need to 
>>> construct them yourself, but you could maybe leverage Mojolicious's 
>>> existing ability to construct such HTTP requests.
>>>
>>> my $embedded_tx = $ua->build_tx(PUT => '/farm/v1/animals/sheep', 
>>> {'If-Match' => 'etag/sheep'}, json => $sheep_data);
>>> ...
>>> my $multipart_tx = $ua->post('/batch/farm/v1' => $headers => multipart 
>>> => [
>>>   {content => $embedded_tx->req->to_string, 'Content-Type' => 
>>> 'application/http'},
>>>   ...
>>> ]);
>>>
>>> Hope that helps,
>>> -Dan
>>>
>>> On Tue, Sep 18, 2018 at 12:50 PM Steve Dondley  
>>> wrote:
>>>
 I'm starting a new thread related to the previous one regarding making 
 a batch api request to Google's API. I keep getting "Bad Reqeust" 
 responses 
 from Google after making a batch API call (other calls work fine).

 Looking at the api documentation for batch api requests 
  it says each 
 part of the multipart request should have a content length. Here is the 
 example Google supplies:

 POST /batch/farm/v1 HTTP/1.1
 Authorization: Bearer your_auth_token
 Host: www.googleapis.com
 Content-Type: multipart/mixed; boundary=batch_foobarbaz
 Content-Length: total_content_length

 --batch_foobarbaz
 Content-Type: application/http
 Content-ID: 

 GET /farm/v1/animals/pony

 --batch_foobarbaz
 Content-Type: application/http
 Content-ID: 

 PUT /farm/v1/animals/sheep
 Content-Type: application/json
 Content-Length: part_content_length
 If-Match: "etag/sheep"

 {
   "animalName": "sheep",
   "animalAge": "5"
   "peltColor": "green",
 }

 --batch_foobarbaz
 Content-Type: application/http
 Content-ID: 

 GET /farm/v1/animals
 If-None-Match: "etag/animals"

 --batch_foobarbaz--



 The requests I'm generating with mojolicious do not have the 
 "part_content_length." Here's mine:

 POST /batch/gmail/v1 HTTP/1.1
 Authorization: Bearer A_REAL_TOKEN_GOES_HERE
 Host: www.googleapis.com
 Accept-Encoding: gzip
 Content-Length: 120
 User-Agent: Mojolicious (Perl)
 Content-Type: multipart/mixed; boundary=nS2CX


 --nS2CX
 Content-Type: application/http


 GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
 --nS2CX--



 My question is, does Mojolicious provide a way to automatically 
 generate a content length header for these parts? If not, which parts of 
 the message get counted 

Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Dan Book
I think you missed something in my post. You should not need to add any
content length headers yourself.

-Dan

On Tue, Sep 18, 2018 at 1:28 PM Steve Dondley  wrote:

> Thanks. It doesn't look like adding the content-length helped. Still
> getting 400 errors. And I just noticed that in Google's example there is no
> content-length header for a GET request. Don't know what else to try now.
>
> On Tuesday, September 18, 2018 at 1:06:23 PM UTC-4, Dan Book wrote:
>>
>> These "parts" are essentially embedded HTTP requests; the lines under
>> each listed GET/PUT/etc are headers for that embedded request. Here is the
>> structure of their example annotated:
>>
>> POST /batch/farm/v1 HTTP/1.1 # actual request and headers
>> Authorization: Bearer your_auth_token
>> Host: www.googleapis.com
>> Content-Type: multipart/mixed; boundary=batch_foobarbaz
>> Content-Length: total_content_length
>> # rest is actual request content
>> --batch_foobarbaz # first multipart segment
>> Content-Type: application/http # multipart segment headers
>> Content-ID: 
>>
>> GET /farm/v1/animals/pony # multipart segment *content*
>>
>> --batch_foobarbaz # second multipart segment
>> Content-Type: application/http # multipart segment headers
>> Content-ID: 
>>
>> PUT /farm/v1/animals/sheep # multipart segment *content*
>> Content-Type: application/json
>> Content-Length: part_content_length
>> If-Match: "etag/sheep"
>>
>> {
>>   "animalName": "sheep",
>>   "animalAge": "5"
>>   "peltColor": "green",
>> }
>>
>> --batch_foobarbaz # third multipart segment
>> Content-Type: application/http # multipart segment headers
>> Content-ID: 
>>
>> GET /farm/v1/animals # multipart segment *content*
>> If-None-Match: "etag/animals"
>>
>> --batch_foobarbaz--
>>
>> As noted the part where the part_content_length is is inside the content
>> for one of the multipart segments. Mojolicious doesn't have anything to
>> deal with the content of multipart segments of this type, so you need to
>> construct them yourself, but you could maybe leverage Mojolicious's
>> existing ability to construct such HTTP requests.
>>
>> my $embedded_tx = $ua->build_tx(PUT => '/farm/v1/animals/sheep',
>> {'If-Match' => 'etag/sheep'}, json => $sheep_data);
>> ...
>> my $multipart_tx = $ua->post('/batch/farm/v1' => $headers => multipart =>
>> [
>>   {content => $embedded_tx->req->to_string, 'Content-Type' =>
>> 'application/http'},
>>   ...
>> ]);
>>
>> Hope that helps,
>> -Dan
>>
>> On Tue, Sep 18, 2018 at 12:50 PM Steve Dondley  wrote:
>>
>>> I'm starting a new thread related to the previous one regarding making a
>>> batch api request to Google's API. I keep getting "Bad Reqeust" responses
>>> from Google after making a batch API call (other calls work fine).
>>>
>>> Looking at the api documentation for batch api requests
>>>  it says each
>>> part of the multipart request should have a content length. Here is the
>>> example Google supplies:
>>>
>>> POST /batch/farm/v1 HTTP/1.1
>>> Authorization: Bearer your_auth_token
>>> Host: www.googleapis.com
>>> Content-Type: multipart/mixed; boundary=batch_foobarbaz
>>> Content-Length: total_content_length
>>>
>>> --batch_foobarbaz
>>> Content-Type: application/http
>>> Content-ID: 
>>>
>>> GET /farm/v1/animals/pony
>>>
>>> --batch_foobarbaz
>>> Content-Type: application/http
>>> Content-ID: 
>>>
>>> PUT /farm/v1/animals/sheep
>>> Content-Type: application/json
>>> Content-Length: part_content_length
>>> If-Match: "etag/sheep"
>>>
>>> {
>>>   "animalName": "sheep",
>>>   "animalAge": "5"
>>>   "peltColor": "green",
>>> }
>>>
>>> --batch_foobarbaz
>>> Content-Type: application/http
>>> Content-ID: 
>>>
>>> GET /farm/v1/animals
>>> If-None-Match: "etag/animals"
>>>
>>> --batch_foobarbaz--
>>>
>>>
>>>
>>> The requests I'm generating with mojolicious do not have the
>>> "part_content_length." Here's mine:
>>>
>>> POST /batch/gmail/v1 HTTP/1.1
>>> Authorization: Bearer A_REAL_TOKEN_GOES_HERE
>>> Host: www.googleapis.com
>>> Accept-Encoding: gzip
>>> Content-Length: 120
>>> User-Agent: Mojolicious (Perl)
>>> Content-Type: multipart/mixed; boundary=nS2CX
>>>
>>>
>>> --nS2CX
>>> Content-Type: application/http
>>>
>>>
>>> GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
>>> --nS2CX--
>>>
>>>
>>>
>>> My question is, does Mojolicious provide a way to automatically generate
>>> a content length header for these parts? If not, which parts of the message
>>> get counted toward this length and how do I calculate it (assuming UTF-8)?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Mojolicious" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to mojolicious...@googlegroups.com.
>>> To post to this group, send email to mojol...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/mojolicious.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You 

Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread sri
Looks to me like it's just normal HTTP requests wrapped in a multipart HTTP 
request.

--
sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Steve Dondley
Thanks. It doesn't look like adding the content-length helped. Still 
getting 400 errors. And I just noticed that in Google's example there is no 
content-length header for a GET request. Don't know what else to try now.

On Tuesday, September 18, 2018 at 1:06:23 PM UTC-4, Dan Book wrote:
>
> These "parts" are essentially embedded HTTP requests; the lines under each 
> listed GET/PUT/etc are headers for that embedded request. Here is the 
> structure of their example annotated:
>
> POST /batch/farm/v1 HTTP/1.1 # actual request and headers
> Authorization: Bearer your_auth_token
> Host: www.googleapis.com
> Content-Type: multipart/mixed; boundary=batch_foobarbaz
> Content-Length: total_content_length
> # rest is actual request content
> --batch_foobarbaz # first multipart segment
> Content-Type: application/http # multipart segment headers
> Content-ID: >
>
> GET /farm/v1/animals/pony # multipart segment *content*
>
> --batch_foobarbaz # second multipart segment
> Content-Type: application/http # multipart segment headers
> Content-ID: >
>
> PUT /farm/v1/animals/sheep # multipart segment *content*
> Content-Type: application/json
> Content-Length: part_content_length
> If-Match: "etag/sheep"
>
> {
>   "animalName": "sheep",
>   "animalAge": "5"
>   "peltColor": "green",
> }
>
> --batch_foobarbaz # third multipart segment
> Content-Type: application/http # multipart segment headers
> Content-ID: >
>
> GET /farm/v1/animals # multipart segment *content*
> If-None-Match: "etag/animals"
>
> --batch_foobarbaz--
>
> As noted the part where the part_content_length is is inside the content 
> for one of the multipart segments. Mojolicious doesn't have anything to 
> deal with the content of multipart segments of this type, so you need to 
> construct them yourself, but you could maybe leverage Mojolicious's 
> existing ability to construct such HTTP requests.
>
> my $embedded_tx = $ua->build_tx(PUT => '/farm/v1/animals/sheep', 
> {'If-Match' => 'etag/sheep'}, json => $sheep_data);
> ...
> my $multipart_tx = $ua->post('/batch/farm/v1' => $headers => multipart => [
>   {content => $embedded_tx->req->to_string, 'Content-Type' => 
> 'application/http'},
>   ...
> ]);
>
> Hope that helps,
> -Dan
>
> On Tue, Sep 18, 2018 at 12:50 PM Steve Dondley  > wrote:
>
>> I'm starting a new thread related to the previous one regarding making a 
>> batch api request to Google's API. I keep getting "Bad Reqeust" responses 
>> from Google after making a batch API call (other calls work fine).
>>
>> Looking at the api documentation for batch api requests 
>>  it says each part 
>> of the multipart request should have a content length. Here is the example 
>> Google supplies:
>>
>> POST /batch/farm/v1 HTTP/1.1
>> Authorization: Bearer your_auth_token
>> Host: www.googleapis.com
>> Content-Type: multipart/mixed; boundary=batch_foobarbaz
>> Content-Length: total_content_length
>>
>> --batch_foobarbaz
>> Content-Type: application/http
>> Content-ID: >
>>
>> GET /farm/v1/animals/pony
>>
>> --batch_foobarbaz
>> Content-Type: application/http
>> Content-ID: >
>>
>> PUT /farm/v1/animals/sheep
>> Content-Type: application/json
>> Content-Length: part_content_length
>> If-Match: "etag/sheep"
>>
>> {
>>   "animalName": "sheep",
>>   "animalAge": "5"
>>   "peltColor": "green",
>> }
>>
>> --batch_foobarbaz
>> Content-Type: application/http
>> Content-ID: >
>>
>> GET /farm/v1/animals
>> If-None-Match: "etag/animals"
>>
>> --batch_foobarbaz--
>>
>>
>>
>> The requests I'm generating with mojolicious do not have the 
>> "part_content_length." Here's mine:
>>
>> POST /batch/gmail/v1 HTTP/1.1
>> Authorization: Bearer A_REAL_TOKEN_GOES_HERE
>> Host: www.googleapis.com
>> Accept-Encoding: gzip
>> Content-Length: 120
>> User-Agent: Mojolicious (Perl)
>> Content-Type: multipart/mixed; boundary=nS2CX
>>
>>
>> --nS2CX
>> Content-Type: application/http
>>
>>
>> GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
>> --nS2CX--
>>
>>
>>
>> My question is, does Mojolicious provide a way to automatically generate 
>> a content length header for these parts? If not, which parts of the message 
>> get counted toward this length and how do I calculate it (assuming UTF-8)?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit 

Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Dan Book
These "parts" are essentially embedded HTTP requests; the lines under each
listed GET/PUT/etc are headers for that embedded request. Here is the
structure of their example annotated:

POST /batch/farm/v1 HTTP/1.1 # actual request and headers
Authorization: Bearer your_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length
# rest is actual request content
--batch_foobarbaz # first multipart segment
Content-Type: application/http # multipart segment headers
Content-ID: 

GET /farm/v1/animals/pony # multipart segment *content*

--batch_foobarbaz # second multipart segment
Content-Type: application/http # multipart segment headers
Content-ID: 

PUT /farm/v1/animals/sheep # multipart segment *content*
Content-Type: application/json
Content-Length: part_content_length
If-Match: "etag/sheep"

{
  "animalName": "sheep",
  "animalAge": "5"
  "peltColor": "green",
}

--batch_foobarbaz # third multipart segment
Content-Type: application/http # multipart segment headers
Content-ID: 

GET /farm/v1/animals # multipart segment *content*
If-None-Match: "etag/animals"

--batch_foobarbaz--

As noted the part where the part_content_length is is inside the content
for one of the multipart segments. Mojolicious doesn't have anything to
deal with the content of multipart segments of this type, so you need to
construct them yourself, but you could maybe leverage Mojolicious's
existing ability to construct such HTTP requests.

my $embedded_tx = $ua->build_tx(PUT => '/farm/v1/animals/sheep',
{'If-Match' => 'etag/sheep'}, json => $sheep_data);
...
my $multipart_tx = $ua->post('/batch/farm/v1' => $headers => multipart => [
  {content => $embedded_tx->req->to_string, 'Content-Type' =>
'application/http'},
  ...
]);

Hope that helps,
-Dan

On Tue, Sep 18, 2018 at 12:50 PM Steve Dondley  wrote:

> I'm starting a new thread related to the previous one regarding making a
> batch api request to Google's API. I keep getting "Bad Reqeust" responses
> from Google after making a batch API call (other calls work fine).
>
> Looking at the api documentation for batch api requests
>  it says each part
> of the multipart request should have a content length. Here is the example
> Google supplies:
>
> POST /batch/farm/v1 HTTP/1.1
> Authorization: Bearer your_auth_token
> Host: www.googleapis.com
> Content-Type: multipart/mixed; boundary=batch_foobarbaz
> Content-Length: total_content_length
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID: 
>
> GET /farm/v1/animals/pony
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID: 
>
> PUT /farm/v1/animals/sheep
> Content-Type: application/json
> Content-Length: part_content_length
> If-Match: "etag/sheep"
>
> {
>   "animalName": "sheep",
>   "animalAge": "5"
>   "peltColor": "green",
> }
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID: 
>
> GET /farm/v1/animals
> If-None-Match: "etag/animals"
>
> --batch_foobarbaz--
>
>
>
> The requests I'm generating with mojolicious do not have the
> "part_content_length." Here's mine:
>
> POST /batch/gmail/v1 HTTP/1.1
> Authorization: Bearer A_REAL_TOKEN_GOES_HERE
> Host: www.googleapis.com
> Accept-Encoding: gzip
> Content-Length: 120
> User-Agent: Mojolicious (Perl)
> Content-Type: multipart/mixed; boundary=nS2CX
>
>
> --nS2CX
> Content-Type: application/http
>
>
> GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
> --nS2CX--
>
>
>
> My question is, does Mojolicious provide a way to automatically generate a
> content length header for these parts? If not, which parts of the message
> get counted toward this length and how do I calculate it (assuming UTF-8)?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Steve Dondley
You can also see my code here: https://perlmonks.org/?node_id=1222593

On Tuesday, September 18, 2018 at 12:55:06 PM UTC-4, Ilya Rassadin wrote:
>
> Hi! 
>
> Please, provide a code example (with any paste service, like 
> gist.github.com), so we can see how you  create request object and give 
> you advice.
>
>
> On 18/09/2018 19:50, Steve Dondley wrote:
>
> I'm starting a new thread related to the previous one regarding making a 
> batch api request to Google's API. I keep getting "Bad Reqeust" responses 
> from Google after making a batch API call (other calls work fine).
>
> Looking at the api documentation for batch api requests 
>  it says each part 
> of the multipart request should have a content length. Here is the example 
> Google supplies: 
>
> POST /batch/farm/v1 HTTP/1.1
> Authorization: Bearer your_auth_token
> Host: www.googleapis.com
> Content-Type: multipart/mixed; boundary=batch_foobarbaz
> Content-Length: total_content_length
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> GET /farm/v1/animals/pony
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> PUT /farm/v1/animals/sheep
> Content-Type: application/json
> Content-Length: part_content_length
> If-Match: "etag/sheep"
>
> {
>   "animalName": "sheep",
>   "animalAge": "5"
>   "peltColor": "green",
> }
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> GET /farm/v1/animals
> If-None-Match: "etag/animals"
>
> --batch_foobarbaz--
>
>
>
> The requests I'm generating with mojolicious do not have the 
> "part_content_length." Here's mine:
>
> POST /batch/gmail/v1 HTTP/1.1
> Authorization: Bearer A_REAL_TOKEN_GOES_HERE
> Host: www.googleapis.com
> Accept-Encoding: gzip
> Content-Length: 120
> User-Agent: Mojolicious (Perl)
> Content-Type: multipart/mixed; boundary=nS2CX
>
>
> --nS2CX
> Content-Type: application/http
>
>
> GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
> --nS2CX--
>
>
>
> My question is, does Mojolicious provide a way to automatically generate a 
> content length header for these parts? If not, which parts of the message 
> get counted toward this length and how do I calculate it (assuming UTF-8)?
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to mojolicious...@googlegroups.com .
> To post to this group, send email to mojol...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Steve Dondley
My code is on another 
thread: https://groups.google.com/forum/#!topic/mojolicious/36fqlY31icg

For now, I'm just trying to figure out how to accurately generate the 
"content-length" for each part of the mulitpart HTTP request.

On Tuesday, September 18, 2018 at 12:55:06 PM UTC-4, Ilya Rassadin wrote:
>
> Hi! 
>
> Please, provide a code example (with any paste service, like 
> gist.github.com), so we can see how you  create request object and give 
> you advice.
>
>
> On 18/09/2018 19:50, Steve Dondley wrote:
>
> I'm starting a new thread related to the previous one regarding making a 
> batch api request to Google's API. I keep getting "Bad Reqeust" responses 
> from Google after making a batch API call (other calls work fine).
>
> Looking at the api documentation for batch api requests 
>  it says each part 
> of the multipart request should have a content length. Here is the example 
> Google supplies: 
>
> POST /batch/farm/v1 HTTP/1.1
> Authorization: Bearer your_auth_token
> Host: www.googleapis.com
> Content-Type: multipart/mixed; boundary=batch_foobarbaz
> Content-Length: total_content_length
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> GET /farm/v1/animals/pony
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> PUT /farm/v1/animals/sheep
> Content-Type: application/json
> Content-Length: part_content_length
> If-Match: "etag/sheep"
>
> {
>   "animalName": "sheep",
>   "animalAge": "5"
>   "peltColor": "green",
> }
>
> --batch_foobarbaz
> Content-Type: application/http
> Content-ID:  
>
> GET /farm/v1/animals
> If-None-Match: "etag/animals"
>
> --batch_foobarbaz--
>
>
>
> The requests I'm generating with mojolicious do not have the 
> "part_content_length." Here's mine:
>
> POST /batch/gmail/v1 HTTP/1.1
> Authorization: Bearer A_REAL_TOKEN_GOES_HERE
> Host: www.googleapis.com
> Accept-Encoding: gzip
> Content-Length: 120
> User-Agent: Mojolicious (Perl)
> Content-Type: multipart/mixed; boundary=nS2CX
>
>
> --nS2CX
> Content-Type: application/http
>
>
> GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
> --nS2CX--
>
>
>
> My question is, does Mojolicious provide a way to automatically generate a 
> content length header for these parts? If not, which parts of the message 
> get counted toward this length and how do I calculate it (assuming UTF-8)?
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to mojolicious...@googlegroups.com .
> To post to this group, send email to mojol...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How do you generate a "Content-Length" header in a multipart request?

2018-09-18 Thread Илья Рассадин

Hi!

Please, provide a code example (with any paste service, like 
gist.github.com), so we can see how you  create request object and give 
you advice.



On 18/09/2018 19:50, Steve Dondley wrote:
I'm starting a new thread related to the previous one regarding making 
a batch api request to Google's API. I keep getting "Bad Reqeust" 
responses from Google after making a batch API call (other calls work 
fine).


Looking at the api documentation for batch api requests 
 it says each 
part of the multipart request should have a content length. Here is 
the example Google supplies:


POST /batch/farm/v1 HTTP/1.1
Authorization: Beareryour_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length:total_content_length

--batch_foobarbaz
Content-Type: application/http
Content-ID: 

GET /farm/v1/animals/pony

--batch_foobarbaz
Content-Type: application/http
Content-ID: 

PUT /farm/v1/animals/sheep
Content-Type: application/json
Content-Length:part_content_length
If-Match: "etag/sheep"

{
   "animalName": "sheep",
   "animalAge": "5"
   "peltColor": "green",
}

--batch_foobarbaz
Content-Type: application/http
Content-ID: 

GET /farm/v1/animals
If-None-Match: "etag/animals"

--batch_foobarbaz--


The requests I'm generating with mojolicious do not have the 
"part_content_length." Here's mine:


|
POST /batch/gmail/v1 HTTP/1.1
Authorization:BearerA_REAL_TOKEN_GOES_HERE
Host:www.googleapis.com
Accept-Encoding:gzip
Content-Length:120
User-Agent:Mojolicious(Perl)
Content-Type:multipart/mixed;boundary=nS2CX


--nS2CX
Content-Type:application/http


GET /gmail/v1/users/sdond...@gmail.com/messages/165eb111fcf21503
--nS2CX--

|


My question is, does Mojolicious provide a way to automatically 
generate a content length header for these parts? If not, which parts 
of the message get counted toward this length and how do I calculate 
it (assuming UTF-8)?


--
You received this message because you are subscribed to the Google 
Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to mojolicious+unsubscr...@googlegroups.com 
.
To post to this group, send email to mojolicious@googlegroups.com 
.

Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.