mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-22 18:00:17 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # pom.xml
This commit is contained in:
commit
88be6d7a68
@ -69,6 +69,14 @@
|
||||
<artifactId>ini4j</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,12 +1,15 @@
|
||||
package net.mamoe.mirai.utils;
|
||||
|
||||
import org.apache.commons.httpclient.util.HttpURLConnection;
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class ImageNetworkUtils {
|
||||
public static void postImage(String ukey, int fileSize, String g_uin,String groupCode, String img){
|
||||
public static void postImage(String ukey, int fileSize, String g_uin,String groupCode, byte[] img){
|
||||
//http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver=5515&term=pc&ukey=” + 删全部空 (ukey) + “&filesize=” + 到文本 (fileSize) + “&range=0&uin=” + g_uin + “&groupcode=” + Group
|
||||
StringBuilder builder = new StringBuilder("http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver=5515&term=pc");
|
||||
builder.append("&ukey=")
|
||||
@ -17,17 +20,14 @@ public class ImageNetworkUtils {
|
||||
.append("&groupcode=").append(groupCode);
|
||||
|
||||
try {
|
||||
Connection.Response response = Jsoup.connect(builder.toString())
|
||||
.ignoreContentType(true)
|
||||
.requestBody(img)
|
||||
.followRedirects(true)
|
||||
.userAgent("QQClient")
|
||||
.header("Content-Length","" + fileSize)
|
||||
.execute();
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(builder.toString()).openConnection();
|
||||
conn.setRequestProperty("User-agent","QQClient");
|
||||
conn.setRequestProperty("Content-length","" + fileSize);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.getOutputStream().write(img);
|
||||
|
||||
System.out.println(response.statusCode());
|
||||
System.out.println(response.statusMessage());
|
||||
System.out.println(response.body());
|
||||
conn.connect();
|
||||
System.out.println(conn.getResponseCode());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user