5、URLConnection(3)

 

Writing data to the server

 

Sometimes you need to write data to the URLConnection

the getOutputStream () method returns an OutputStream

It can be used to write data to the server

 

Since then URLConnection output is not allowed by default

It must be called setDoOutput (true) method prior to re-request output stream

GET request method will become POST

 

Step submit form data:

 

 

 

 

 

URLConnection security concerns

There are some common security restrictions establish a network connection, read and write files, etc.

URLConnection objects to be bound by these security limitations

 

The URL of the connection permissions needed

No permissions will return null

 

URLConnection subclasses will but hava.security.Permission different subclasses

 

 

 Guess MIME media type

 

Content guess the name of the object file attempts to expand according to UR

As a result of the speculation String Returns

 

Try to see the first few bytes to guess the content stream type

 

HTTPURLConnection

 

 

 Request method

 

 

Disconnect from server

 

Response processing server

 

 

 

Redirect

 

 

 proxy

 

 

Guess you like

Origin www.cnblogs.com/Mrchengs/p/10929820.html