Skip to content

Commit 25c2bd2

Browse files
committed
♻️
1 parent 45fa1d8 commit 25c2bd2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/java/com/github/plexpt/chatgpt/Chatbot.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Chatbot {
2626
private String cfClearance;
2727
private String userAgent;
2828
private String parentId;
29-
private Map<String, String> headers;
29+
private Map<String, String> headers = new HashMap<>();
3030

3131
private String conversationIdPrev;
3232
private String parentIdPrev;
@@ -260,12 +260,15 @@ public void refreshSession() {
260260
// Set cookies
261261
session.getCookies().put("__Secure-next-auth.session-token", sessionToken);
262262
session.getCookies().put("cf_clearance", cfClearance);
263+
Map<String, String> map = new HashMap<>();
264+
map.put("User-Agent", userAgent);
265+
session.setHeaders(map);
263266

264267
String urlSession = "https://chat.openai.com/api/auth/session";
265-
HttpResponse response = session.get2(urlSession,
266-
Collections.singletonMap("User-Agent", userAgent));
268+
HttpResponse response = session.get2(urlSession);
269+
267270
if (response.getStatus() != 200) {
268-
System.out.println("err code: " + response.getStatus());
271+
System.err.println("err code: " + response.getStatus());
269272
System.out.println("cf_clearance: " + cfClearance);
270273
System.out.println("token: " + sessionToken);
271274
System.out.println("userAgent: " + userAgent);

src/main/java/com/github/plexpt/chatgpt/Session.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ public Response get(String url, Map<String, String> data) {
6868
return response;
6969
}
7070

71-
public HttpResponse get2(String url, Map<String, String> data) {
71+
public HttpResponse get2(String url) {
7272
getCookiesString();
7373

74-
Map<String, Object> map = new HashMap<>(data);
7574
return HttpUtil.createGet(url)
7675
.addHeaders(headers)
7776
.cookie(getCookiesString())
78-
.form(map)
7977
.execute();
8078
}
8179

0 commit comments

Comments
 (0)