2017-03-19 3 views
0

저는 AngularJS에 처음 왔으며, Headless Drupal 인터페이스를 만드는 데이 작업을 사용하고 있습니다. 검색 한 후RESTful 서비스를 통해 콘텐츠를 만드는 헤드리스 Drupal

//test function 
$scope.test = function() { 
    console.log("NODE Test function responding!"); 
    var user_session = $cookieStore.get('user_session'); 
    console.log(user_session); 

    var nodeObj = { 
    "title": "Node Test", 
    "body": "Node body contents test#2", 
    "type": "page" 
    }; 
    var nodeObj = { 
    "type": "page", 
    "title": "New Page", 
    "language": "und" 
    }; 

    var res = $http.post("http://mydrupal-services-site/angularjs-headless/api/v1/node", nodeObj, { 
    "headers": user_session 
    }); 
    res.success(function(data, status, headers, config) { 
    $scope.message = data; 
    console.log("Success: "); 
    console.log(data); 
    }); 
    res.error(function(data, status, headers, config) { 
    console.error(data); 
    }); 
} 

, 내가 LimitRequestFieldSize 16384를 추가 제안 게시물을 발견 : 여기

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>400 Bad Request</title> 
</head><body> 
<h1>Bad Request</h1> 
<p>Your browser sent a request that this server could not understand.<br /> 
The number of request header fields exceeds this server's limit.</p> 
<hr> 
<address>Apache/2.4.7 (Ubuntu) Server at 127.0.0.1 Port 80</address> 
</body></html> 

내가 사용하고 코드입니다 :

나는 다음과 같은 오류가 발생하는 문제에 충돌했습니다 내 VirtualHost에 문제를 해결할 수 있지만 그것을하지 않았다. 귀하는 기본적으로 헤더에 최대 8킬로바이트을 보낼 수있는

Cookie:SESSb22b2ff3837c37411e0b1da3fbd77b0c=_bwpgljhXPwcA_ZfmZpL2IrnIvo25PX_APYdzrIcM08 X-CSRF-Token:GwXcAwctxVcOi_FvI-Mfm6HYQaLoWAFnvkQQ-Nnzbhs 
+0

제 질문에 대한 답변을 확인하십시오. 귀하의 user_session 쿠키가 6028 자 이상이어야합니다. – lin

+0

안녕하세요 @ 린, 내 user_session 데이터는 단지 144 자 길이입니다. 질문에 대한 업데이트로 포함했습니다. – sisko

+0

HTTP 요청에서 보내는 전체 요청 헤더를 추가 할 수 있습니까? (콘솔에서 네트워크 탭의 원시 출력) – lin

답변

0

The number of request header fields exceeds this server's limit.

:

UPDATE

user_session 변수는 (긴에만 144 자입니다) 다음을 포함 (apache2). 그런 식으로 {"headers": user_session}은 머리말에서 길게 보낼 것이다. 노드 객체에 추가하거나 사용자 세션 문자열을 최대 8KB (6.028 자)로 줄이십시오. Btw. nodeObj을 두 번 연속 정의하십시오. 문제는 drupal과 관련이 없습니다.

$scope.test = function() { 
    var nodeObj = { 
    "title": "Node Test", 
    "body": "Node body contents test#2", 
    "type": "page", 
    "userSession": $cookieStore.get('user_session') 
    }; 

    $http.post(
    "http://mydrupal-services-site/angularjs-headless/api/v1/node", 
    nodeObj 
).then(function(data, status, headers, config) { 
    $scope.message = data; 
    console.log("Success:"); 
    console.log(data); 
    }).then(function(data, status, headers, config) { 
    console.error(data); 
    }); 
} 
+0

의견을 보내 주셔서 감사합니다. 나는 내 쿠키의 길이를 테스트했고 그것은 144자를 넘지 않았습니다. 나는 또한 귀하의 코드 제안을 시도했지만 그것은 나를 위해 작동하지 않았다 – sisko

+0

@sisko 귀하의 HTTP 요청에 의해 보내지는 전체 요청 헤더를 추가 할 수 있습니까? (콘솔의 네트워크 탭 원시 출력) – lin