New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid character in cookie value #8

Open
alexandrefett opened this Issue May 18, 2018 · 10 comments

Comments

Projects
None yet
6 participants
@alexandrefett

alexandrefett commented May 18, 2018

Invalid character in cookie value, code unit: '34'

Dio dio = new Dio();
  dio.options = new Options(
      baseUrl: Endpoint.BASE_URL,
      connectTimeout: 5000,
      receiveTimeout: 10000,
      // 5s
      headers: {
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
        "Accept-Encoding": "gzip"
      }
  );
Future basePage() async {
    Response response = await client.get("https://www.instagram.com");
    print(response.data);
  }
@wendux

This comment has been minimized.

Member

wendux commented May 18, 2018

Could you paste the stacktrace ?

@alexandrefett

This comment has been minimized.

alexandrefett commented May 18, 2018

Unhandled exception:
FormatException: Invalid character in cookie value, code unit: '34'
#0 _Cookie._validate (dart:io/http_headers.dart:995)
#1 new _Cookie (dart:io/http_headers.dart:844)
#2 new Cookie (dart:io/http.dart:868)
#3 Instagram.basePage... (package:instascrapper/instascrapper.dart:45:31)

@jave1987

This comment has been minimized.

jave1987 commented Jun 5, 2018

i have same error

@jave1987

This comment has been minimized.

jave1987 commented Jun 5, 2018

[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
DioError [DioErrorType.DEFAULT]: FormatException: Invalid character in cookie name, code unit: '58'

@wendux

This comment has been minimized.

Member

wendux commented Jun 5, 2018

@jave1987 what's your request url ?

@jave1987

This comment has been minimized.

jave1987 commented Jun 5, 2018

I fix it , there is '@' in url

@thismachinechills

This comment has been minimized.

thismachinechills commented Jul 6, 2018

Can confirm the same error with Instagram and other sites.

edit: This seems to stem from an issue in dart's standard library. I created a push request with a fix here: dart-lang/sdk#33765

@jackxuechen

This comment has been minimized.

jackxuechen commented Jul 10, 2018

@thismachinechills
I also encountered this problem when using dio in the project of flutter. How should I use the code you submitted

@Blankeer

This comment has been minimized.

Blankeer commented Aug 5, 2018

I have encountered the same problem, how to solve it ...
DioError [DioErrorType.DEFAULT]: FormatException: Invalid character in cookie value, code unit: '34'

@wendux

This comment has been minimized.

Member

wendux commented Sep 18, 2018

In my box I run the code as follows:

  try {
    Response r = await dio.get("https://www.instagram.com");
    print(r.headers);
  }on DioError catch(e){
     print(e);
     print(e.response.statusCode);
  }

It works well,and the log:

connection: keep-alive
cache-control: private, no-cache, no-store, must-revalidate
set-cookie: sessionid=""; Domain=instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: rur=PRN; Domain=.instagram.com; Path=/
set-cookie: mid=W6B4uAAEAAHsy45UUgwJdX2vQLf5; Domain=.instagram.com; expires=Fri, 15 Sep 2028 04:02:00 GMT; Max-Age=315360000; Path=/
set-cookie: mcd=3; Domain=.instagram.com; expires=Fri, 15 Sep 2028 04:02:00 GMT; Path=/
set-cookie: csrftoken=ZnlfxdwG4v7zmFE3Kz5wmuPPcG8HQN4g; expires=Tue, 17-Sep-2019 04:02:00 GMT; Max-Age=31449600; Path=/; Secure
date: Tue, 18 Sep 2018 04:02:00 GMT
content-encoding: gzip
vary: Accept-Language, Cookie, Accept-Encoding
strict-transport-security: max-age=60
pragma: no-cache
content-type: text/html; charset=utf-8
content-language: en
content-security-policy-report-only: report-uri /security/csp_report/; default-src * data: blob:; script-src https://*.instagram.com https://*.cdninstagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net wss://*.instagram.com 'unsafe-inline' 'unsafe-eval' blob: data: 'self'; style-src data: blob: 'unsafe-inline' *; connect-src https://*.instagram.com https://*.cdninstagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net 'self' chrome-extension://boadgeojelhgndaghljhdicfkmllpafd; block-all-mixed-content; frame-ancestors 'self'; frame-src 'self' https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'
content-length: 7935
x-frame-options: SAMEORIGIN
expires: Sat, 01 Jan 2000 00:00:00 GMT

my dart version:

Dart VM version: 2.1.0-dev.4.0 (Fri Sep 7 16:44:38 2018 +0200) on "macos_x64"

It seems to be the lower version Dart SDK bug, and has been fixed dart-lang/sdk@a9ad427.

@wendux wendux changed the title from Dificult with cookies to Invalid character in cookie value Sep 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment