GJL commented on a change in pull request #6706: [hotfix][doc] Fix curl example
in upload jar example
URL: https://github.com/apache/flink/pull/6706#discussion_r218582712
##########
File path:
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarUploadHeaders.java
##########
@@ -73,7 +73,7 @@ public static JarUploadHeaders getInstance() {
public String getDescription() {
return "Uploads a jar to the cluster. The jar must be sent as
multi-part data. Make sure that the \"Content-Type\"" +
" header is set to \"application/x-java-archive\", as
some http libraries do not add the header by default.\n" +
- "Using 'curl' you can upload a jar via 'curl -X POST -H
\"Expect:\" -F \"jarfile=#path/to/flink-job.jar\" http://hostname:port" + URL +
"'.";
+ "Using 'curl' you can upload a jar via 'curl -X POST -F
\"jarfile=@path/to/flink-job.jar;type=application/x-java-archive\"
http://hostname:port" + URL + "'.";
Review comment:
Thanks for following up @satybald.
For file upload, we use [Content-Type:
multipart/form-data](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data).
The requests consists of multiple parts, where each part has its own HTTP
headers. For the individual parts, you can set `Content-Type:
application/x-java-archive` by using the `type=...` syntax. Using `-H
Content-Type: application/...` results in a HTTP request that is not following
the specification. I found that when working with Flink 1.6.0, it does not
matter what you put after `type=`.
For me the command below works (note the `type=foo/bar`):
```
curl -vvv -X POST -H "Expect:" -F
"jarfile=@examples/streaming/WordCount.jar;type=foo/bar"
```
output:
```
http://localhost:8081/jars/upload
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8081 (#0)
> POST /jars/upload HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 10286
> Content-Type: multipart/form-data;
boundary=------------------------1fdbe0626a9f0009
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Access-Control-Allow-Origin: *
< Connection: keep-alive
< content-length: 197
<
* Connection #0 to host localhost left intact
{"filename":"/var/folders/43/ghpk0br14m99tnl9b86lwfsm0000gn/T/flink-web-5891eaeb-bcb7-41f8-8d20-1647dc1c576f/flink-web-upload/1d287180-8151-423d-b6d2-31ce955bfcb1_WordCount.jar","status":"success"}%
```
I can also omit `type=` and it still works. What Flink and curl version are
you using? I would change the documentation accordingly if the Content-type is
not needed because it causes confusion.
```
curl --version
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20
zlib/1.2.11 nghttp2/1.24.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3
pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL
libz HTTP2 UnixSockets HTTPS-proxy
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services